Object TimeUtils
-
- All Implemented Interfaces:
public class TimeUtils
-
-
Method Summary
Modifier and Type Method Description final static LonggetUnixTimeInSeconds()Gets current unix timestamp in seconds. final static StringgetISO8601Date(Date date)Gets the ISO 8601 formatted with colon time zone, second precision date Stringfor the provide date using the system local time zone.final static StringgetISO8601Date()Gets the ISO 8601 formatted with colon time zone, second precision date Stringfor the provide date using the system local time zone.final static StringgetISO8601DateNoColon(Date date)Gets the ISO 8601 formatted with no colon time zone, second precision date Stringfor the provide date using the system local time zone.final static StringgetISO8601DateNoColon()Gets the ISO 8601 formatted with no colon time zone, second precision date Stringfor the provide date using the system local time zone.final static StringgetISO8601UTCDateWithMilliseconds(Date date)Gets the ISO 8601 formatted with UTC(Z) time zone, millisecond precision date Stringfor the provided date using the UTC +0 time zone.final static StringgetISO8601UTCDateWithMilliseconds()Gets the ISO 8601 formatted with UTC(Z) time zone, millisecond precision date Stringfor the provided date using the UTC +0 time zone.final static StringgetISO8601FullDate(Date date)Gets the ISO 8601 formatted full date Stringfor the provided date using the system local time zone.final static StringgetISO8601FullDate()Gets the ISO 8601 formatted full date Stringfor the provided date using the system local time zone.final static DateparseRFC2822Date(String rfc2822Date, TimeZone timeZone, Locale locale)Parses the RFC-2822 formatted date string rfc2822Date into a Date final static StringgetRFC2822Date(Long epoch, TimeZone timeZone, Locale locale)Converts the epoch into a RFC-2822 date string pattern - RFC2822_DATE_PATTERN -
-
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
Stringfor 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
-
getISO8601Date
@JvmOverloads() final static String getISO8601Date()
Gets the ISO 8601 formatted with colon time zone, second precision date
Stringfor 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
Stringfor 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
-
getISO8601DateNoColon
@JvmOverloads() final static String getISO8601DateNoColon()
Gets the ISO 8601 formatted with no colon time zone, second precision date
Stringfor 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
Stringfor 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.
-
getISO8601UTCDateWithMilliseconds
@JvmOverloads() final static String getISO8601UTCDateWithMilliseconds()
Gets the ISO 8601 formatted with UTC(Z) time zone, millisecond precision date
Stringfor 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
Stringfor 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
-
getISO8601FullDate
@JvmOverloads() final static String getISO8601FullDate()
Gets the ISO 8601 formatted full date
Stringfor 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 parsedtimeZone- the timezone that should be usedlocale- 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 DatetimeZone- the timezone that should be usedlocale- the locale whose date format symbols should be used- Returns:
a RFC-2822 formatted date string for the epoch provided
-
-
-
-