Class DateTimeUtils


  • public class DateTimeUtils
    extends java.lang.Object
    Date/Time utility methods.
    Since:
    5.0.0
    • Constructor Summary

      Constructors 
      Constructor Description
      DateTimeUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.time.ZonedDateTime convertToZonedDateTime​(java.lang.String value)
      Convert to zoned date time.
      static java.util.Date dateOf​(java.time.chrono.ChronoZonedDateTime time)
      Gets Date for ZonedDateTime.
      static java.util.Date dateOf​(java.time.Instant time)
      Gets Date for Instant.
      static java.util.Date dateOf​(java.time.LocalDate time)
      Date of local date.
      static java.util.Date dateOf​(java.time.LocalDateTime time)
      Date of local date time.
      static java.time.LocalDate localDateTime​(long time)
      Local date time local date.
      static java.time.LocalDateTime localDateTimeOf​(long time)
      Local date time of local date time.
      static java.time.LocalDateTime localDateTimeOf​(java.lang.String value)
      Parse the given value as a local datetime.
      static java.time.LocalDateTime localDateTimeOf​(java.util.Date time)
      Local date time of local date time.
      static java.sql.Timestamp timestampOf​(java.time.chrono.ChronoZonedDateTime time)
      Gets Timestamp for ZonedDateTime.
      static java.time.temporal.ChronoUnit toChronoUnit​(java.util.concurrent.TimeUnit tu)
      To chrono unit.
      static java.util.concurrent.TimeUnit toTimeUnit​(java.time.temporal.ChronoUnit tu)
      To time unit time unit.
      static java.time.ZonedDateTime zonedDateTimeOf​(long time)
      Utility for creating a ZonedDateTime object from a millisecond timestamp.
      static java.time.ZonedDateTime zonedDateTimeOf​(long time, java.time.ZoneId zoneId)
      Utility for creating a ZonedDateTime object from a millisecond timestamp.
      static java.time.ZonedDateTime zonedDateTimeOf​(java.lang.String value)
      Parse the given value as a zoned datetime.
      static java.time.ZonedDateTime zonedDateTimeOf​(java.time.Instant time)
      Zoned date time.
      static java.time.ZonedDateTime zonedDateTimeOf​(java.time.temporal.TemporalAccessor time)
      Utility for creating a ZonedDateTime object from a ZonedDateTime.
      static java.time.ZonedDateTime zonedDateTimeOf​(java.util.Calendar time)
      Gets ZonedDateTime for Calendar.
      static java.time.ZonedDateTime zonedDateTimeOf​(java.util.Date time)
      Gets ZonedDateTime for Date.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DateTimeUtils

        public DateTimeUtils()
    • Method Detail

      • localDateTimeOf

        public static java.time.LocalDateTime localDateTimeOf​(java.lang.String value)
        Parse the given value as a local datetime.
        Parameters:
        value - the value
        Returns:
        the date/time instance
      • localDateTimeOf

        public static java.time.LocalDateTime localDateTimeOf​(long time)
        Local date time of local date time.
        Parameters:
        time - the time
        Returns:
        the local date time
      • localDateTimeOf

        public static java.time.LocalDateTime localDateTimeOf​(java.util.Date time)
        Local date time of local date time.
        Parameters:
        time - the time
        Returns:
        the local date time
      • localDateTime

        public static java.time.LocalDate localDateTime​(long time)
        Local date time local date.
        Parameters:
        time - the time
        Returns:
        the local date
      • zonedDateTimeOf

        public static java.time.ZonedDateTime zonedDateTimeOf​(java.lang.String value)
        Parse the given value as a zoned datetime.
        Parameters:
        value - the value
        Returns:
        the date/time instance
      • zonedDateTimeOf

        public static java.time.ZonedDateTime zonedDateTimeOf​(java.time.temporal.TemporalAccessor time)
        Utility for creating a ZonedDateTime object from a ZonedDateTime.
        Parameters:
        time - ZonedDateTime to be copied
        Returns:
        ZonedDateTime representing time
      • zonedDateTimeOf

        public static java.time.ZonedDateTime zonedDateTimeOf​(java.time.Instant time)
        Zoned date time.
        Parameters:
        time - the time
        Returns:
        the zoned date time
      • zonedDateTimeOf

        public static java.time.ZonedDateTime zonedDateTimeOf​(long time)
        Utility for creating a ZonedDateTime object from a millisecond timestamp.
        Parameters:
        time - Milliseconds since Epoch UTC
        Returns:
        ZonedDateTime representing time
      • zonedDateTimeOf

        public static java.time.ZonedDateTime zonedDateTimeOf​(long time,
                                                              java.time.ZoneId zoneId)
        Utility for creating a ZonedDateTime object from a millisecond timestamp.
        Parameters:
        time - Milliseconds since Epoch
        zoneId - Time zone
        Returns:
        ZonedDateTime representing time
      • zonedDateTimeOf

        public static java.time.ZonedDateTime zonedDateTimeOf​(java.util.Date time)
        Gets ZonedDateTime for Date.
        Parameters:
        time - Time object to be converted.
        Returns:
        ZonedDateTime representing time
      • zonedDateTimeOf

        public static java.time.ZonedDateTime zonedDateTimeOf​(java.util.Calendar time)
        Gets ZonedDateTime for Calendar.
        Parameters:
        time - Time object to be converted.
        Returns:
        ZonedDateTime representing time
      • dateOf

        public static java.util.Date dateOf​(java.time.chrono.ChronoZonedDateTime time)
        Gets Date for ZonedDateTime.
        Parameters:
        time - Time object to be converted.
        Returns:
        Date representing time
      • dateOf

        public static java.util.Date dateOf​(java.time.LocalDate time)
        Date of local date.
        Parameters:
        time - the time
        Returns:
        the date
      • dateOf

        public static java.util.Date dateOf​(java.time.LocalDateTime time)
        Date of local date time.
        Parameters:
        time - the time
        Returns:
        the date
      • dateOf

        public static java.util.Date dateOf​(java.time.Instant time)
        Gets Date for Instant.
        Parameters:
        time - Time object to be converted.
        Returns:
        Date representing time
      • timestampOf

        public static java.sql.Timestamp timestampOf​(java.time.chrono.ChronoZonedDateTime time)
        Gets Timestamp for ZonedDateTime.
        Parameters:
        time - Time object to be converted.
        Returns:
        Timestamp representing time
      • convertToZonedDateTime

        public static java.time.ZonedDateTime convertToZonedDateTime​(java.lang.String value)
        Convert to zoned date time.
        Parameters:
        value - the value
        Returns:
        the zoned date time
      • toTimeUnit

        public static java.util.concurrent.TimeUnit toTimeUnit​(java.time.temporal.ChronoUnit tu)
        To time unit time unit.
        Parameters:
        tu - the tu
        Returns:
        the time unit
      • toChronoUnit

        public static java.time.temporal.ChronoUnit toChronoUnit​(java.util.concurrent.TimeUnit tu)
        To chrono unit.
        Parameters:
        tu - the tu
        Returns:
        the chrono unit