Package emissary.util
Class TimeUtil
- java.lang.Object
-
- emissary.util.TimeUtil
-
public class TimeUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static DateTimeFormatterDATE_FULL_ISO_8601static DateTimeFormatterDATE_ISO_8601static DateTimeFormatterDATE_ISO_8601_SSSstatic DateTimeFormatterDATE_ORDINALstatic DateTimeFormatterDATE_ORDINAL_WITH_TIMEstatic DateTimeFormatterDATE_WITH_SLASHES
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringconvertHexDate(String hexDate)Parses hex date string into formatted string ("yyyy-MM-dd HH:mm:ss.SSS")static StringgetCurrentDate()Get current date/time as a slash separated path component (yyyy-MM-dd/HH/mm)static StringgetCurrentDateFullISO8601()Get current date/time as full ISO-8601 string yyyy-MM-dd'T'HH:mm:ss'Z'static StringgetCurrentDateISO8601()Get current date/time as ISO-8601 stringstatic StringgetCurrentDateOrdinal()Get current date as yyyyjjjstatic StringgetDate(String format, String timeZone)Get current date/time formatted as specifiedstatic StringgetDate(TemporalAccessor date, String format, ZoneId timeZone)Given a date, format it with the given patternstatic StringgetDateAsFullISO8601(TemporalAccessor date)Get specified date object as a full ISO-8601 string (yyyy-MM-dd'T'HH:mm:ss'Z')static StringgetDateAsISO8601(long time)Get specified time as ISO-8601 stringstatic StringgetDateAsISO8601(TemporalAccessor date)Get specified date object as ISO-8601 string (yyyy-MM-dd HH:mm:ss)static StringgetDateAsPath(TemporalAccessor date)Get specified date/time as a slash separated path component (yyyy-MM-dd/HH/mm)static StringgetDateOrdinal(TemporalAccessor date)Get current date as yyyyjjjstatic StringgetDateOrdinalWithTime(Instant d)static StringgetISO8601DateFormatString()static ZoneIdgetTimezone()Get the application configured timezonestatic ZonedDateTimegetZonedDateFromISO8601(String dateString)Deprecated.replaced byFlexibleDateTimeParser.parse(String)
-
-
-
Field Detail
-
DATE_WITH_SLASHES
public static final DateTimeFormatter DATE_WITH_SLASHES
-
DATE_ISO_8601
public static final DateTimeFormatter DATE_ISO_8601
-
DATE_FULL_ISO_8601
public static final DateTimeFormatter DATE_FULL_ISO_8601
-
DATE_ORDINAL
public static final DateTimeFormatter DATE_ORDINAL
-
DATE_ISO_8601_SSS
public static final DateTimeFormatter DATE_ISO_8601_SSS
-
DATE_ORDINAL_WITH_TIME
public static final DateTimeFormatter DATE_ORDINAL_WITH_TIME
-
-
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 specificationtimeZone- tz to use, defaults to GMT- Throws:
DateTimeException- if the ID format is invalidZoneRulesException- if checking availability and the zone ID cannot be foundIllegalArgumentException- 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 formatformat- the date formattimeZone- the time zone id- Returns:
- the formatted date
- Throws:
DateTimeException- if the ID format is invalidZoneRulesException- if checking availability and the zone ID cannot be foundIllegalArgumentException- 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.replaced byFlexibleDateTimeParser.parse(String)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()
-
-