public interface TimeIndex extends Comparable<TimeIndex>
The design assumes that TimeIndex is implemented as an immutable object.
TimeDomain
Modifier and Type | Method and Description |
---|---|
TimeIndex |
add(long increment)
Return a new time index with the time incremented from this one.
|
long |
asLong()
Return the numeric index.
|
int |
asOffset()
Return the time as an offset from the origin.
|
TimeIndex |
convert(TimeDomain domain)
Return a new time index by converting this one to the given time domain.
|
TimeIndex |
convert(TimeDomain domain,
Adjustment adjustment)
Return a new time index by converting this one to the given time domain,
possibly adjusting the time as specified.
|
int |
getDay()
Return the day component of the time.
|
TimeIndex |
getDayByRank(Resolution referencePeriod,
DayOfWeek day,
int rank)
Return the TimeIndex for a day defined by name and rank within a reference period.
|
DayOfWeek |
getDayOfWeek()
Return the day of the week.
|
int |
getFractionalSecond()
Return the sub-second component of the time.
|
int |
getHour()
Return the hour component of the time.
|
int |
getMinute()
Return the minute component of the time.
|
int |
getMonth()
Return the month component of the time.
|
int |
getSecond()
Return the second component of the time.
|
TimeDomain |
getTimeDomain()
Return the time domain.
|
long |
getYear()
Return the year component of the time.
|
long |
sub(TimeIndex time)
Return the number of time units since the time specified as argument.
|
String |
toString(String format)
Return a string representation of the time.
|
String |
toString(TimeFormatter formatter)
Return a string representation of the time.
|
compareTo
TimeDomain getTimeDomain()
long asLong()
int asOffset() throws T2Exception
T2Exception
DayOfWeek getDayOfWeek() throws T2Exception
T2Exception
TimeIndex getDayByRank(Resolution referencePeriod, DayOfWeek day, int rank) throws T2Exception
referencePeriod
- one of the values MONTH or YEARday
- the day namerank
- the day rankT2Exception
int getFractionalSecond()
int getSecond()
int getMinute()
int getHour()
int getDay()
int getMonth()
long getYear()
TimeIndex add(long increment) throws T2Exception
This method is related to sub(TimeIndex)
.
increment
- positive or negative number of units to addT2Exception
long sub(TimeIndex time) throws T2Exception
This method is related to add(long)
in the following way:
time
- a non-null time index to substract from this time indexT2Exception
TimeIndex convert(TimeDomain domain) throws T2Exception
domain
- a non-null time domainT2Exception
TimeIndex convert(TimeDomain domain, Adjustment adjustment) throws T2Exception
domain
- a non-null time domainadjustment
- a non-null allowed adjustmentT2Exception
String toString(String format)
For example "%04d%02d%02d"
would produce 19700401 and
"%3$d.%2$d.%1$04d"
would produce 1.4.1970.
As a special trick, when the format string is empty, the date is returned in the compact format d.m.yy, with the day and month without a leading zero, and the year starting at the 3d digit.
If the argument is null, formatting is delegated to the default time formatter defined in the time factory.
In case of errors in the format string, an IllegalFormatException is thrown.
format
- a format string, or an empty string, or nullString toString(TimeFormatter formatter)
formatter
- a time formatter or nullCopyright © 2017. All rights reserved.