Class TemporalConverterDefault

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 standard Temporal types.
See Also:
  • Method Details

    • convertToInstant

      public Instant convertToInstant(Object value)
      Parameters:
      value - the Object to convert. Most likely a Temporal but may also be something else.
      Returns:
      the converted Instant if conversion was possible. Otherwise null.
    • convertToLocalDateTime

      public LocalDateTime convertToLocalDateTime(Object value)
      Parameters:
      value - the Object to convert. Most likely a Temporal but may also be something else.
      Returns:
      the converted LocalDateTime if conversion was possible. Otherwise null.
    • convertToOffsetDateTime

      public OffsetDateTime convertToOffsetDateTime(Object value)
      Parameters:
      value - the Object to convert. Most likely a Temporal but may also be something else.
      Returns:
      the converted OffsetDateTime if conversion was possible. Otherwise null.
    • convertToZonedDateTime

      public ZonedDateTime convertToZonedDateTime(Object value)
      Parameters:
      value - the Object to convert. Most likely a Temporal but may also be something else.
      Returns:
      the converted ZonedDateTime if conversion was possible. Otherwise null.
    • convertToLocalDate

      public LocalDate convertToLocalDate(Object value)
      Parameters:
      value - the Object to convert. Most likely a Temporal but may also be something else.
      Returns:
      the converted LocalDate if conversion was possible. Otherwise null.
    • convertToLocalTime

      public LocalTime convertToLocalTime(Object value)
      Parameters:
      value - the Object to convert. Most likely a Temporal but may also be something else.
      Returns:
      the converted LocalTime if conversion was possible. Otherwise null.
    • convertToOffsetTime

      public OffsetTime convertToOffsetTime(Object value)
      Parameters:
      value - the Object to convert. Most likely a Temporal but may also be something else.
      Returns:
      the converted OffsetTime if conversion was possible. Otherwise null.
    • convertAndEvaluate

      public <T> T convertAndEvaluate(Object temporal1, Object temporal2, BiFunction<?,?,T> function)
      Specified by:
      convertAndEvaluate in interface TemporalConverter
      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 BiFunction with the given temporal values applied or null if the a temporal value has an unknown or unsupported type.
    • get

      public static TemporalConverterDefault get()
      Returns:
      the singleton instance.