public class TimeFactory extends Object implements TimeDomain, TimePacker, TimeFormatter, TimeScanner
TimeIndex objects and
acts as an immutable TimeDomain.
A time domain is defined by the following 4 properties:
Resolution,
BasePeriodPattern,
SubPeriodPatternBASE_YEAR_FOR_NANO, DAYS_TO_19700101, DAYS_TO_20000101| Constructor and Description |
|---|
TimeFactory(TimeDomainDefinition def)
Constructor providing a default time formatter and time scanner.
|
TimeFactory(TimeDomainDefinition def,
TimeFormatter formatter)
Constructor providing a default time scanner.
|
TimeFactory(TimeDomainDefinition def,
TimeFormatter formatter,
TimeScanner scanner)
Construct a TimeFactory for the given time domain.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareResolutionTo(Resolution unit)
Return a negative, zero, positive number if the resolution is higher,
the same, or lower than the argument.
|
boolean |
equals(Object obj) |
String |
format(TimeParts timeParts)
Generate a string representing the time in the time parts object.
|
BasePeriodPattern |
getBasePeriodPattern()
Return the base period pattern.
|
int |
getBasePeriodSize()
Return the number of time points within a base period.
|
TimeIndex |
getBasePeriodStart(TimeIndex t)
Return the time index of the first time point in the base period containing
the time specified.
|
DayOfWeek |
getDayOfWeek(TimeIndex time)
Return the day of week for the given time.
|
TimeFormatter |
getFormatter()
Return the time formatter to use when formatting times in this domain.
|
String |
getLabel()
Return the label of the time domain, uniquely identifying the domain when
using a
TimeDomainCatalog. |
long |
getOrigin()
Return the origin of the time domain.
|
TimePacker |
getPacker()
Return the time packer to use for processing times in this domain.
|
Resolution |
getResolution()
Return the resolution of the time domain.
|
TimeScanner |
getScanner()
Return the time scanner to use when scanning strings as times in this domain.
|
SubPeriodPattern |
getSubPeriodPattern()
Return the sub period pattern.
|
int |
hashCode() |
TimeIndex |
maxTime()
Return a new TimeIndex giving the maximum time in this domain.
|
TimeIndex |
maxTime(boolean offsetCompatible)
Return a new TimeIndex giving the maximum time in this domain.
|
TimeIndex |
minTime()
Return a new TimeIndex giving the minimum time in this domain.
|
TimeIndex |
minTime(boolean offsetCompatible)
Return a new TimeIndex giving the minimum time in this domain.
|
long |
pack(TimeParts tp,
Adjustment adjust)
Pack the component elements of the time into a numeric time index.
|
void |
requireEquality(TimeDomain domain)
Throw an exception if the domain is not equal to this domain.
|
TimeParts |
scan(Resolution unit,
String time)
Scan the date string into a time parts object.
|
boolean |
similar(TimeDomain domain)
Compare to another time domain, ignoring label.
|
TimeIndex |
time(long index)
Return a new TimeIndex corresponding to the given index.
|
TimeIndex |
time(long year,
int month,
int day,
int hour,
int min,
int sec,
int usec,
Adjustment adjust)
Return a new TimeIndex corresponding to the list of parameters.
|
TimeIndex |
time(String date)
Return a new TimeIndex corresponding to the given date string.
|
TimeIndex |
time(String date,
Adjustment adjust)
Return a new TimeIndex corresponding to the given date string.
|
TimeIndex |
timeFromOffset(long offset)
Return a new TimeIndex corresponding to the given offset.
|
String |
toString() |
TimeParts |
unpack(long time)
Unpack the numeric representation of time into its component elements.
|
boolean |
valid(long t,
boolean testOnly)
Return true if the numeric time index is valid for the domain.
|
public TimeFactory(TimeDomainDefinition def, TimeFormatter formatter, TimeScanner scanner)
def - a non-null time domain definitionformatter - a non-null time formatterscanner - a non-null time scannerpublic TimeFactory(TimeDomainDefinition def)
def - a non-null time domain definitionpublic TimeFactory(TimeDomainDefinition def, TimeFormatter formatter)
def - a non-null time domain definitionformatter - a non-null time formatterpublic TimePacker getPacker()
TimeDomaingetPacker in interface TimeDomainpublic TimeFormatter getFormatter()
TimeDomaingetFormatter in interface TimeDomainpublic TimeScanner getScanner()
TimeDomaingetScanner in interface TimeDomainpublic String getLabel()
TimeDomainTimeDomainCatalog.getLabel in interface TimeDomainpublic long getOrigin()
TimeDomaingetOrigin in interface TimeDomainpublic Resolution getResolution()
TimeDomaingetResolution in interface TimeDomainpublic int compareResolutionTo(Resolution unit)
TimeDomaincompareResolutionTo in interface TimeDomainunit - a non-null resolutionpublic void requireEquality(TimeDomain domain) throws T2Exception
TimeDomainrequireEquality in interface TimeDomaindomain - a time domainT2Exceptionpublic boolean similar(TimeDomain domain)
TimeDomainsimilar in interface TimeDomaindomain - a time domainpublic TimeIndex time(long year, int month, int day, int hour, int min, int sec, int usec, Adjustment adjust) throws T2Exception
TimeDomain
See the comment in TimeDomain.time(String) for important details about
discarding unnecessary time components.
time in interface TimeDomainyear - the yearmonth - the monthday - the dayhour - the hourmin - the minutesec - the secondusec - the microsecondadjust - a non-null adjustment modeT2Exceptionpublic TimeIndex time(String date) throws T2Exception
TimeDomainDefaultTimeScanner.
Date and time components too precise for the resolution of the time domain are discarded. As an example, all time components are discarded when the resolution is daily or less. There are cases where the time components have an effect on a date component. In such cases it is necessary to use first a higher resolution time domain then to convert to the wanted domain. An example of such a case is when the time component includes a time zone offset which changes the day (and possibly the month and year, as on January first or December 31).
time in interface TimeDomaindate - a non-null date stringT2Exceptionpublic TimeIndex time(String date, Adjustment adjust) throws T2Exception
TimeDomainDefaultTimeScanner.
See the comment in TimeDomain.time(String) for important details about
discarding unnecessary time components.
time in interface TimeDomaindate - a non-null date stringadjust - a non-null adjustment modeT2Exceptionpublic TimeIndex minTime()
TimeDomainminTime(false).minTime in interface TimeDomainpublic TimeIndex maxTime()
TimeDomainmaxTime(false).maxTime in interface TimeDomainpublic TimeIndex minTime(boolean offsetCompatible)
TimeDomainminTime in interface TimeDomainoffsetCompatible - if true, return a TimeIndex representable as an offsetTimeIndex.asOffset()public TimeIndex maxTime(boolean offsetCompatible)
TimeDomainmaxTime in interface TimeDomainoffsetCompatible - if true, return a TimeIndex representable as an offsetTimeIndex.asOffset()public TimeIndex time(long index)
TimeDomaintime in interface TimeDomainindex - a numberpublic TimeIndex timeFromOffset(long offset)
TimeDomaintimeFromOffset in interface TimeDomainoffset - a number to be added to the domain's originpublic boolean valid(long t,
boolean testOnly)
throws T2Exception
TimePackervalid in interface TimePackert - numeric time to validatetestOnly - if true do not throw an exception when time is not validT2Exceptionpublic BasePeriodPattern getBasePeriodPattern()
TimePackergetBasePeriodPattern in interface TimePackerpublic SubPeriodPattern getSubPeriodPattern()
TimePackergetSubPeriodPattern in interface TimePackerpublic TimeParts scan(Resolution unit, String time) throws T2Exception
TimeScannerscan in interface TimeScannerunit - the time resolutiontime - a non-null string containing a date and time specificationTimePartsT2Exceptionpublic String format(TimeParts timeParts)
TimeFormatterformat in interface TimeFormattertimeParts - a non-null time parts objectpublic long pack(TimeParts tp, Adjustment adjust) throws T2Exception
TimePackerpack in interface TimePackertp - a time parts objectadjust - a non-null adjustment modeT2Exceptionpublic TimeParts unpack(long time)
TimePackerunpack in interface TimePackertime - a numeric time indexpublic DayOfWeek getDayOfWeek(TimeIndex time) throws T2Exception
TimePackergetDayOfWeek in interface TimePackertime - a time indexT2Exceptionpublic int getBasePeriodSize()
TimePackergetBasePeriodSize in interface TimePackerpublic TimeIndex getBasePeriodStart(TimeIndex t)
TimePackergetBasePeriodStart in interface TimePackert - a non-null time index, which must be from this time domainCopyright © 2017. All rights reserved.