public class DefaultTimeScanner extends Object implements TimeScanner
The page 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) :
The scanner does not interpret numbers itself and from its point of view, hour 42 and minute 88 are fine. Thedate-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).
scan(ch.agent.t2.time.Resolution, java.lang.String)
method returns a TimeParts object, but there is no guarantee
that the date and time components have already been validated when the method
returns. The responsibility for validating numbers falls to
TimeTools.makeRawIndex(ch.agent.t2.time.Resolution, ch.agent.t2.time.TimeParts)
.
For the validation to succeed, the components must have the following values:
There are some differences between the calendar date and time representation supported here and ISO 8601:2004:
The time resolution is only used to help the interpretation of fractional seconds. It could be used to decide which time parts to ignore, but this tasks is left to the "packing" step. On the other hand fractional seconds need to be interpreted by the scanner because of ambiguities.
Constructor and Description |
---|
DefaultTimeScanner() |
Modifier and Type | Method and Description |
---|---|
TimeParts |
scan(Resolution unit,
String datetime)
Scan the date string into a time parts object.
|
public TimeParts scan(Resolution unit, String datetime) throws T2Exception
TimeScanner
scan
in interface TimeScanner
unit
- the time resolutiondatetime
- a non-null string containing a date and time specificationTimeParts
T2Exception
Copyright © 2017. All rights reserved.