Package org.alfresco.util
Class ISO8601DateFormat
java.lang.Object
org.alfresco.util.ISO8601DateFormat
Formatting support for ISO 8601 dates
sYYYY-MM-DDThh:mm:ss.sssTZDwhere:
- sYYYY Four-digit year with optional leading positive (+) or negative (-) sign. A negative sign indicates a year BCE. The absence of a sign or the presence of a positive sign indicates a year CE (for example, -0055 would indicate the year 55 BCE, while +1969 and 1969 indicate the year 1969 CE).
- MM Two-digit month (01 = January, etc.)
- DD Two-digit day of month (01 through 31)
- hh Two digits of hour (00 through 23)
- mm Two digits of minute (00 through 59)
- ss.sss Seconds, to three decimal places (00.000 through 59.999)
- TZD Time zone designator (either Z for Zulu, i.e. UTC, or +hh:mm or -hh:mm, i.e. an offset from UTC)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Format date into ISO format (UCT0 / Zulu)static String
formatToZulu
(String isoDate) Normalise isoDate time to Zulu(UTC0) time-zone, removing any UTC offset.static Calendar
Get a calendar object from cache for the system default timezone.static Calendar
getCalendar
(TimeZone timezone) Get a calendar object from cache.static boolean
isTimeComponentDefined
(String isoDate) Checks whether or not the given ISO8601-formatted date-string contains a time-component instead of only the actual date.static Date
Parse date from ISO formatted string.static Date
Parse date from ISO formatted string, with an explicit timezone specifiedstatic Date
parseDayOnly
(String isoDate, TimeZone timezone) Parses the given ISO8601-formatted date-string, not taking into account the time-component.static Date
parseInternal
(String isoDate, TimeZone timezone) Parse date from ISO formatted string, either in the specified TimeZone, or with TimeZone information taken from the date
-
Field Details
-
UTC_TIMEZONE
-
-
Constructor Details
-
ISO8601DateFormat
public ISO8601DateFormat()
-
-
Method Details
-
getCalendar
Get a calendar object from cache.- Parameters:
timezone
- timezone object to indicate the timezone to be used by the returned calendar object- Returns:
- calendar object from cache or newly created (if cache is empty)
-
getCalendar
Get a calendar object from cache for the system default timezone.- Returns:
- calendar object from cache or newly created (if cache is empty)
-
format
Format date into ISO format (UCT0 / Zulu)- Parameters:
isoDate
- the date to format- Returns:
- the ISO Zulu timezone formatted string
-
formatToZulu
Normalise isoDate time to Zulu(UTC0) time-zone, removing any UTC offset.- Parameters:
isoDate
-- Returns:
- the ISO Zulu timezone formatted string e.g 2011-02-04T17:13:14.000+01:00 -> 2011-02-04T16:13:14.000Z
-
parse
Parse date from ISO formatted string. The ISO8601 date must include TimeZone offset information- Parameters:
isoDate
- ISO string to parse- Returns:
- the date
- Throws:
AlfrescoRuntimeException
- if the parse failed
-
parse
Parse date from ISO formatted string, with an explicit timezone specified- Parameters:
isoDate
- ISO string to parsetimezone
- The TimeZone the date is in- Returns:
- the date
- Throws:
AlfrescoRuntimeException
- if the parse failed
-
parseInternal
Parse date from ISO formatted string, either in the specified TimeZone, or with TimeZone information taken from the date- Parameters:
isoDate
- ISO string to parsetimezone
- The time zone, null means default time zone- Returns:
- the date
- Throws:
AlfrescoRuntimeException
- if the parse failed
-
isTimeComponentDefined
Checks whether or not the given ISO8601-formatted date-string contains a time-component instead of only the actual date.- Parameters:
isoDate
-- Returns:
- true, if time is present.
-
parseDayOnly
Parses the given ISO8601-formatted date-string, not taking into account the time-component. The time-information for the will be reset to zero.- Parameters:
isoDate
- the day (formatted sYYYY-MM-DD) or a full date (sYYYY-MM-DDThh:mm:ss.sssTZD)timezone
- the timezone to use- Returns:
- the parsed date
- Throws:
AlfrescoRuntimeException
- if the parsing failed.
-