Object TimeUtils

  • All Implemented Interfaces:

    
    public class TimeUtils
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static TimeUtils INSTANCE
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final static Long getUnixTimeInSeconds() Gets current unix timestamp in seconds.
      final static String getISO8601Date(Date date) Gets the ISO 8601 formatted with colon time zone, second precision date String for the provide date using the system local time zone.
      final static String getISO8601Date() Gets the ISO 8601 formatted with colon time zone, second precision date String for the provide date using the system local time zone.
      final static String getISO8601DateNoColon(Date date) Gets the ISO 8601 formatted with no colon time zone, second precision date String for the provide date using the system local time zone.
      final static String getISO8601DateNoColon() Gets the ISO 8601 formatted with no colon time zone, second precision date String for the provide date using the system local time zone.
      final static String getISO8601UTCDateWithMilliseconds(Date date) Gets the ISO 8601 formatted with UTC(Z) time zone, millisecond precision date String for the provided date using the UTC +0 time zone.
      final static String getISO8601UTCDateWithMilliseconds() Gets the ISO 8601 formatted with UTC(Z) time zone, millisecond precision date String for the provided date using the UTC +0 time zone.
      final static String getISO8601FullDate(Date date) Gets the ISO 8601 formatted full date String for the provided date using the system local time zone.
      final static String getISO8601FullDate() Gets the ISO 8601 formatted full date String for the provided date using the system local time zone.
      final static Date parseRFC2822Date(String rfc2822Date, TimeZone timeZone, Locale locale) Parses the RFC-2822 formatted date string rfc2822Date into a Date
      final static String getRFC2822Date(Long epoch, TimeZone timeZone, Locale locale) Converts the epoch into a RFC-2822 date string pattern - RFC2822_DATE_PATTERN
      • Methods inherited from class java.lang.Object

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

    • Method Detail

      • getUnixTimeInSeconds

         final static Long getUnixTimeInSeconds()

        Gets current unix timestamp in seconds.

        Returns:

        {code long} current timestamp

      • getISO8601Date

        @JvmOverloads() final static String getISO8601Date(Date date)

        Gets the ISO 8601 formatted with colon time zone, second precision date String for the provide date using the system local time zone.

        Date pattern used is ISO8601_TIMEZONE_ISO8601_3X_PRECISION_SECOND which has timezone ISO 8601 'XXX' pattern, which gives a timezone of ex: "-07:00" ("Z" for UTC +0) Ex: (device in time zone "America/Los_Angeles") Wed Nov 30 11:53:09.497 GMT-07:00 2022 -> 2022-11-30T11:53:09-07:00

        Parameters:
        date - the Date to apply the formatting to; defaults to the current Date
        Returns:

        date String formatted as ISO 8601 with colon time zone, second precision

      • getISO8601Date

        @JvmOverloads() final static String getISO8601Date()

        Gets the ISO 8601 formatted with colon time zone, second precision date String for the provide date using the system local time zone.

        Date pattern used is ISO8601_TIMEZONE_ISO8601_3X_PRECISION_SECOND which has timezone ISO 8601 'XXX' pattern, which gives a timezone of ex: "-07:00" ("Z" for UTC +0) Ex: (device in time zone "America/Los_Angeles") Wed Nov 30 11:53:09.497 GMT-07:00 2022 -> 2022-11-30T11:53:09-07:00

        Returns:

        date String formatted as ISO 8601 with colon time zone, second precision

      • getISO8601DateNoColon

        @JvmOverloads() final static String getISO8601DateNoColon(Date date)

        Gets the ISO 8601 formatted with no colon time zone, second precision date String for the provide date using the system local time zone.

        Date pattern used is ISO8601_TIMEZONE_ISO8601_2X_PRECISION_SECOND which has timezone ISO 8601 'XX' pattern, which gives a timezone of ex: "-0700" ("Z" for UTC +0) Ex: (device in time zone "America/Los_Angeles") Wed Nov 30 11:53:09.497 GMT-07:00 2022 -> 2022-11-30T11:53:09-0700

        Parameters:
        date - the Date to apply the formatting to; defaults to the current Date
        Returns:

        date String formatted as ISO 8601 with no colon time zone, second precision

      • getISO8601DateNoColon

        @JvmOverloads() final static String getISO8601DateNoColon()

        Gets the ISO 8601 formatted with no colon time zone, second precision date String for the provide date using the system local time zone.

        Date pattern used is ISO8601_TIMEZONE_ISO8601_2X_PRECISION_SECOND which has timezone ISO 8601 'XX' pattern, which gives a timezone of ex: "-0700" ("Z" for UTC +0) Ex: (device in time zone "America/Los_Angeles") Wed Nov 30 11:53:09.497 GMT-07:00 2022 -> 2022-11-30T11:53:09-0700

        Returns:

        date String formatted as ISO 8601 with no colon time zone, second precision

      • getISO8601UTCDateWithMilliseconds

        @JvmOverloads() final static String getISO8601UTCDateWithMilliseconds(Date date)

        Gets the ISO 8601 formatted with UTC(Z) time zone, millisecond precision date String for the provided date using the UTC +0 time zone.

        Date pattern used is ISO8601_TIMEZONE_ISO8601_UTCZ_PRECISION_MILLISECOND which has timezone ISO 8601 'Z' char terminator, which gives a timezone of 'Z'. Ex: Wed Nov 30 11:53:09.497 GMT-07:00 2022 -> 2022-11-30T18:53:09.497Z (notice the hour shift because the date must be evaluated from UTC +0)

        Note that ISO 8601 requires date strings terminating with the char 'Z' to be in the time zone UTC +0 (no offset).

        AMSDK-10273 :: ExEdge requires time zone offset formatted in form +-HH:MM.

        Parameters:
        date - the Date to apply the formatting to; defaults to the current Date
        Returns:

        date String formatted as ISO 8601 with UTC(Z) time zone, millisecond precision

      • getISO8601UTCDateWithMilliseconds

        @JvmOverloads() final static String getISO8601UTCDateWithMilliseconds()

        Gets the ISO 8601 formatted with UTC(Z) time zone, millisecond precision date String for the provided date using the UTC +0 time zone.

        Date pattern used is ISO8601_TIMEZONE_ISO8601_UTCZ_PRECISION_MILLISECOND which has timezone ISO 8601 'Z' char terminator, which gives a timezone of 'Z'. Ex: Wed Nov 30 11:53:09.497 GMT-07:00 2022 -> 2022-11-30T18:53:09.497Z (notice the hour shift because the date must be evaluated from UTC +0)

        Note that ISO 8601 requires date strings terminating with the char 'Z' to be in the time zone UTC +0 (no offset).

        AMSDK-10273 :: ExEdge requires time zone offset formatted in form +-HH:MM.

        Returns:

        date String formatted as ISO 8601 with UTC(Z) time zone, millisecond precision

      • getISO8601FullDate

        @JvmOverloads() final static String getISO8601FullDate(Date date)

        Gets the ISO 8601 formatted full date String for the provided date using the system local time zone.

        Date pattern used is ISO8601_FULL_DATE Ex: Wed Nov 30 11:53:09.497 GMT-07:00 2022 -> 2022-11-30

        Parameters:
        date - the Date to apply the formatting to; defaults to the current Date
        Returns:

        date String formatted as ISO 8601 full date, using system local time zone

      • getISO8601FullDate

        @JvmOverloads() final static String getISO8601FullDate()

        Gets the ISO 8601 formatted full date String for the provided date using the system local time zone.

        Date pattern used is ISO8601_FULL_DATE Ex: Wed Nov 30 11:53:09.497 GMT-07:00 2022 -> 2022-11-30

        Returns:

        date String formatted as ISO 8601 full date, using system local time zone

      • parseRFC2822Date

         final static Date parseRFC2822Date(String rfc2822Date, TimeZone timeZone, Locale locale)

        Parses the RFC-2822 formatted date string rfc2822Date into a Date

        Parameters:
        rfc2822Date - RFC-2822 formatted date string to be parsed
        timeZone - the timezone that should be used
        locale - the locale whose date format symbols should be used
        Returns:

        a valid date from the RF-2822 date if successful, null otherwise

      • getRFC2822Date

         final static String getRFC2822Date(Long epoch, TimeZone timeZone, Locale locale)

        Converts the epoch into a RFC-2822 date string pattern - RFC2822_DATE_PATTERN

        Parameters:
        epoch - the epoch (milliseconds) that should be converted to Date
        timeZone - the timezone that should be used
        locale - the locale whose date format symbols should be used
        Returns:

        a RFC-2822 formatted date string for the epoch provided