- java.lang.Object
-
- io.github.mmm.base.temporal.TemporalConverterDefault
-
- All Implemented Interfaces:
TemporalConverter
- Direct Known Subclasses:
TemporalConverterLegacy
public class TemporalConverterDefault extends Object implements TemporalConverter
Simple utility class to convert to standardTemporaltypes.- See Also:
get()
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TconvertAndEvaluate(Object temporal1, Object temporal2, BiFunction<?,?,T> function)InstantconvertToInstant(Object value)LocalDateconvertToLocalDate(Object value)LocalDateTimeconvertToLocalDateTime(Object value)LocalTimeconvertToLocalTime(Object value)OffsetDateTimeconvertToOffsetDateTime(Object value)OffsetTimeconvertToOffsetTime(Object value)ZonedDateTimeconvertToZonedDateTime(Object value)static TemporalConverterDefaultget()
-
-
-
Method Detail
-
convertToLocalDateTime
public LocalDateTime convertToLocalDateTime(Object value)
- Parameters:
value- theObjectto convert. Most likely aTemporalbut may also be something else.- Returns:
- the converted
LocalDateTimeif conversion was possible. Otherwisenull.
-
convertToOffsetDateTime
public OffsetDateTime convertToOffsetDateTime(Object value)
- Parameters:
value- theObjectto convert. Most likely aTemporalbut may also be something else.- Returns:
- the converted
OffsetDateTimeif conversion was possible. Otherwisenull.
-
convertToZonedDateTime
public ZonedDateTime convertToZonedDateTime(Object value)
- Parameters:
value- theObjectto convert. Most likely aTemporalbut may also be something else.- Returns:
- the converted
ZonedDateTimeif conversion was possible. Otherwisenull.
-
convertToOffsetTime
public OffsetTime convertToOffsetTime(Object value)
- Parameters:
value- theObjectto convert. Most likely aTemporalbut may also be something else.- Returns:
- the converted
OffsetTimeif conversion was possible. Otherwisenull.
-
convertAndEvaluate
public <T> T convertAndEvaluate(Object temporal1, Object temporal2, BiFunction<?,?,T> function)
- Specified by:
convertAndEvaluatein interfaceTemporalConverter- Type Parameters:
T- type of the result.- Parameters:
temporal1- the first temporal value (with date and/or time).temporal2- the second temporal value (with date and/or time).function- the function to apply on the two given temporal values after assuring they are of same type. This method will therefore convert on of the given temporal values so it has the same type as the other one.- Returns:
- the result of the given
BiFunctionwith the given temporal values applied ornullif the a temporal value has an unknown or unsupported type.
-
get
public static TemporalConverterDefault get()
- Returns:
- the singleton instance.
-
-