public class Converter extends Object
convert(1234.5678d).intoDecimal() returns a BigDecimal of 1234.5678
convert(1234.5678d).intoInteger() returns a rounded int of 1235
convert("2015-03").intoLocalDateTime() returns a LocalDateTime of 2015-03-01T00:00:00.000
convert(Optional.of("8484")).intoDouble() returns a double of 8484.0
Supports conversions from most basic types, in addition to java.util.Date & java.time instances,
object arrays, Iterables, Maps & Optionals + more from #toString conversions| Modifier and Type | Field and Description |
|---|---|
protected Object |
o
wrapped inner value, the conversion target
|
| Modifier and Type | Method and Description |
|---|---|
static Converter |
convert(Object value) |
BigDecimal |
intoDecimal() |
boolean |
intoDecimalWorks() |
double |
intoDouble() |
boolean |
intoDoubleWorks() |
int |
intoInteger() |
boolean |
intoIntegerWorks() |
List |
intoList()
Converts the inner value into a List
will convert a Map into a value list
will convert simple types into a size 1 list [?]
as such this should always work
|
boolean |
intoListWorks() |
LocalDateTime |
intoLocalDateTime()
Converts to string & permissively parses as a date, ignoring time zone
defaults day->1, month->1, hour->0, minute->0, second->0, nanoseconds->0
|
boolean |
intoLocalDateTimeWorks() |
long |
intoLong() |
boolean |
intoLongWorks() |
Map |
intoMap()
Converts the inner value into a Map
will convert an Iterable into an index -> value map
will convert simple types into a size 1 map of {"value": ?}
as such this should always work
|
boolean |
intoMapWorks() |
String |
intoString()
Converts the inner value into a String, should always work
|
boolean |
intoStringWorks() |
ZonedDateTime |
intoZonedDateTime()
Converts to string & permissively parses as a date, requiring a time zone to be parsed
defaults day->1, month->1, hour->0, minute->0, second->0, nanoseconds->0
|
ZonedDateTime |
intoZonedDateTimeOrUse(ZoneId fallback)
Converts to string & permissively parses as a date, uses parsed time zone or falls back on input
defaults day->1, month->1, hour->0, minute->0, second->0, nanoseconds->0, time-zone->input
|
boolean |
intoZonedDateTimeWorks() |
ConverterMaybe |
maybe() |
protected final Object o
public static Converter convert(Object value)
value - some object to convertpublic String intoString()
public boolean intoStringWorks()
intoString() will not throw an exceptionpublic int intoInteger()
RuntimeException - cannot be convertedpublic boolean intoIntegerWorks()
intoInteger() will not throw an exceptionpublic long intoLong()
RuntimeException - cannot be convertedpublic boolean intoLongWorks()
intoLong() will not throw an exceptionpublic double intoDouble()
RuntimeException - cannot be convertedpublic boolean intoDoubleWorks()
intoDouble() will not throw an exceptionpublic BigDecimal intoDecimal()
RuntimeException - cannot be convertedpublic boolean intoDecimalWorks()
intoDecimal() will not throw an exceptionpublic Map intoMap()
public boolean intoMapWorks()
intoMap() will not throw an exceptionpublic List intoList()
public boolean intoListWorks()
intoList() will not throw an exceptionpublic LocalDateTime intoLocalDateTime()
DateTimeParseException - converted string is in an invalid formatpublic boolean intoLocalDateTimeWorks()
intoLocalDateTime() will not throw an exceptionpublic ZonedDateTime intoZonedDateTime()
DateTimeParseException - converted string is in an invalid formatpublic boolean intoZonedDateTimeWorks()
intoZonedDateTime() will not throw an exceptionpublic ZonedDateTime intoZonedDateTimeOrUse(ZoneId fallback)
fallback - time zone to use if value has noneDateTimeParseException - converted string is in an invalid formatpublic ConverterMaybe maybe()
Copyright © 2017. All rights reserved.