Package io.jmix.core

Class DateTimeTransformations

java.lang.Object
io.jmix.core.DateTimeTransformations

@Component("core_DateTimeTransformations") public class DateTimeTransformations extends Object
  • Constructor Details

    • DateTimeTransformations

      public DateTimeTransformations()
  • Method Details

    • transformToType

      public Object transformToType(Object date, Class javaType, @Nullable ZoneId zoneId)
      Converts a date instance to the passed java type corresponding to one of the date types.
      Parameters:
      date - the date object, not null
      javaType - the java type to convert to
      zoneId - the zone ID to use or null to use default system timezone
      Returns:
      the date object converted to the passed java type, not null
    • transformToZDT

      public ZonedDateTime transformToZDT(Object date)
      Obtains an instance of ZonedDateTime from Date or LocalDate or LocalDateTime or OffsetDateTime ZonedDateTime is created for LocalDate, LocalDateTime with default system timezone
      Parameters:
      date - date object, not null
      Returns:
      the ZonedDateTime, not null
    • transformToZDT

      protected ZonedDateTime transformToZDT(Object date, @Nullable ZoneId fromZoneId)
    • transformFromZDT

      public Object transformFromZDT(ZonedDateTime zonedDateTime, Class javaType)
      Obtains an instance of specified by type date object from from ZonedDateTime LocalDate, LocalDateTime is created for default system timezone
      Parameters:
      zonedDateTime - date object, not null
      javaType - date type to transformation from ZonedDateTime
      Returns:
      the date object, not null
    • transformFromZdtInternal

      protected Object transformFromZdtInternal(ZonedDateTime zonedDateTime, Class javaType)
    • transformToLocalTime

      public LocalTime transformToLocalTime(Object date)
      Obtains an instance of LocalTime from Time or Date or LocalTime or OffsetTime
      Parameters:
      date - date object, not null
      Returns:
      the LocalTime, not null
    • transformFromLocalTime

      public Object transformFromLocalTime(LocalTime localTime, Class javaType)
      Obtains an instance of specified by type date object from from LocalTime
      Parameters:
      localTime - date object, not null
      javaType - date type to transformation from LocalTime
      Returns:
      the date object, not null
    • isDateTypeSupportsTimeZones

      public boolean isDateTypeSupportsTimeZones(Class javaType)
      Check if date type supports time zone conversation
      Parameters:
      javaType - - date type
      Returns:
      true - if date type supports timezones