kipedia.org/wiki/ISO_8601">ISO 8601 at Wikipedia describes the standard and provides a link to the official document.
DefaultExternalFormat scans combined dates and times agreeing with the following syntax (here in pseudo-code) :
date-time := date-time-basic|date-time-extended date-time-basic := date-basic[Ttime-basic[Z|(+|-time-basic)]] date-basic := yyyy[mm[dd]] time-basic := hh[mm[ss[,|.u{1,6}]]] date-time-extended := date-extended[T| time-extended[Z|(+|-time-extended)]] date-extended := (+y+)?yyyy[-mm[-dd]] time-extended := hh[:mm[:ss[,|.u{1-6}]]]
Meta syntax: meta elements in italic; literals underlined; a single lowercase letter represents a single digit; * means zero or more; + means one or more; ? means zero or one; {n,m} means n to m times; optional elements in square brackets; alternatives separated by vertical bar; parentheses for grouping.
The fields represented by lowercase letters are year (y), month (m), day (d), hour (h), minute (m), second (s), fraction of a second (u).
The scanner does not interpret numbers itself and from its point of view, hour 42 and minute 88 are fine. The {@link DefaultExternalFormat#scan(String) scan(String)} method returns a TimeParts object, but there is noguarantee that the date and time components have already been validated when the method returns. The responsibility for validating numbers falls to {@link TimeParts#asRawIndex(Resolution)}.
For the validation to succeed, the components must have the following values:
- year non-negative;
- month in [1, 12];
- day in [1, n], where n is the last day of the month;
- hour in [0, 24] with 24 valid only when minute and second are 0;
- minute in [0, 59];
- second in [0, 60], with 60 (leap second) only tolerated on last of June and December;
- microsecond in [0, 999999].
There are some differences between the calendar date and time representation supported here and ISO 8601:2004:
- years cannot be negative;
- years can only have more than 4 digits in the extended format;
- time can only be combined with a full date, with year, month, and day specified;
- in the extended format, date and time can be separated by a space;
- a decimal fraction can only be added to seconds;
- the time zone designator Z is redundant because the "local" time of the the Time2 Library is always UTC;
- a time zone offset can have microsecond precision.
@author Jean-Paul Vetterli