Package emissary.util

Class TimeUtil


  • public class TimeUtil
    extends Object
    • Method Detail

      • getTimezone

        public static ZoneId getTimezone()
        Get the application configured timezone
        Returns:
        the timezone
      • getDate

        public static String getDate​(String format,
                                     @Nullable
                                     String timeZone)
        Get current date/time formatted as specified
        Parameters:
        format - the specification
        timeZone - tz to use, defaults to GMT
        Throws:
        DateTimeException - if the ID format is invalid
        ZoneRulesException - if checking availability and the zone ID cannot be found
        IllegalArgumentException - if the pattern is invalid
      • getDate

        @Nullable
        public static String getDate​(@Nullable
                                     TemporalAccessor date,
                                     String format,
                                     @Nullable
                                     ZoneId timeZone)
        Given a date, format it with the given pattern
        Parameters:
        date - the date to format
        format - the date format
        timeZone - the time zone id
        Returns:
        the formatted date
        Throws:
        DateTimeException - if the ID format is invalid
        ZoneRulesException - if checking availability and the zone ID cannot be found
        IllegalArgumentException - if the pattern is invalid
      • getCurrentDate

        public static String getCurrentDate()
        Get current date/time as a slash separated path component (yyyy-MM-dd/HH/mm)
        Returns:
        the formatted date in the form yyyy-MM-dd/HH/mm
        Throws:
        DateTimeException - if an error occurs during formatting
      • getDateAsPath

        @Nullable
        public static String getDateAsPath​(@Nullable
                                           TemporalAccessor date)
        Get specified date/time as a slash separated path component (yyyy-MM-dd/HH/mm)
        Parameters:
        date - to format
        Returns:
        the formatted date in the form yyyy-MM-dd/HH/mm
        Throws:
        DateTimeException - if an error occurs during formatting
      • getCurrentDateOrdinal

        public static String getCurrentDateOrdinal()
        Get current date as yyyyjjj
        Returns:
        the formatted date in the form yyyyjjj
        Throws:
        DateTimeException - if an error occurs during formatting
      • getDateOrdinal

        @Nullable
        public static String getDateOrdinal​(@Nullable
                                            TemporalAccessor date)
        Get current date as yyyyjjj
        Parameters:
        date - to format
        Returns:
        the formatted date in the form yyyyjjj
        Throws:
        DateTimeException - if an error occurs during formatting
      • getCurrentDateISO8601

        public static String getCurrentDateISO8601()
        Get current date/time as ISO-8601 string
        Returns:
        String in the format yyyy-MM-dd HH:mm:ss
        Throws:
        DateTimeException - if an error occurs during formatting
      • getDateAsISO8601

        public static String getDateAsISO8601​(long time)
        Get specified time as ISO-8601 string
        Returns:
        String in the format yyyy-MM-dd HH:mm:ss
        Throws:
        DateTimeException - if an error occurs during formatting
      • getDateAsISO8601

        @Nullable
        public static String getDateAsISO8601​(@Nullable
                                              TemporalAccessor date)
        Get specified date object as ISO-8601 string (yyyy-MM-dd HH:mm:ss)
        Parameters:
        date - to format
        Returns:
        String in the format yyyy-MM-dd HH:mm:ss
        Throws:
        DateTimeException - if an error occurs during formatting
      • getCurrentDateFullISO8601

        public static String getCurrentDateFullISO8601()
        Get current date/time as full ISO-8601 string yyyy-MM-dd'T'HH:mm:ss'Z'
        Returns:
        String in the format yyyy-MM-dd'T'HH:mm:ss'Z'
        Throws:
        DateTimeException - if an error occurs during formatting
      • getDateAsFullISO8601

        @Nullable
        public static String getDateAsFullISO8601​(@Nullable
                                                  TemporalAccessor date)
        Get specified date object as a full ISO-8601 string (yyyy-MM-dd'T'HH:mm:ss'Z')
        Parameters:
        date - to format
        Returns:
        the formatted date in yyyy-MM-dd'T'HH:mm:ss'Z'
        Throws:
        DateTimeException - if an error occurs during formatting
      • getZonedDateFromISO8601

        @Nullable
        @Deprecated
        public static ZonedDateTime getZonedDateFromISO8601​(@Nullable
                                                            String dateString)
        Deprecated.
        Get Date object from ISO-8601 formatted string ("yyyy-MM-dd HH:mm:ss")
        Parameters:
        dateString - the string representation of the date in the format yyyy-MM-dd HH:mm:ss
        Returns:
        ZonedDateTime parsed from the string
        Throws:
        DateTimeParseException - if string is not in the proper format
      • convertHexDate

        public static String convertHexDate​(String hexDate)
        Parses hex date string into formatted string ("yyyy-MM-dd HH:mm:ss.SSS")
        Parameters:
        hexDate - hex string representation of the date
        Returns:
        converted time in string format yyyy-MM-dd HH:mm:ss.SSS
        Throws:
        DateTimeParseException - if could not parse date
      • getISO8601DateFormatString

        public static String getISO8601DateFormatString()
      • getDateOrdinalWithTime

        public static String getDateOrdinalWithTime​(Instant d)