| Constructor and Description |
|---|
TimePeriod(TimeUnit timeUnit,
long periodLength)
Create a new time period with the given unit of time and period length.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
double |
frequencyPer(TimePeriod otherTimePeriod)
Compute and return the number of times this time period occurs in the given time period.
|
static TimePeriod |
halfCentury()
Create and return a new TimePeriod representing one half of a century
|
static TimePeriod |
halfDay()
Create and return a new TimePeriod representing one half of a day.
|
static TimePeriod |
halfDecade()
Create and return a new TimePeriod representing one half of a decade.
|
static TimePeriod |
halfHour()
Create and return a new TimePeriod representing one half of an hour.
|
static TimePeriod |
halfMonth()
Create and return a new TimePeriod representing one half of a month.
|
static TimePeriod |
halfSecond()
Create and return a new TimePeriod representing one half of a second.
|
static TimePeriod |
halfYear()
Create and return a new TimePeriod representing one half of a year.
|
int |
hashCode() |
static TimePeriod |
oneCentury()
Create and return a new TimePeriod representing exactly one century.
|
static TimePeriod |
oneDay()
Create and return a new TimePeriod representing one day.
|
static TimePeriod |
oneDecade()
Create and return a new TimePeriod representing exactly one decade.
|
static TimePeriod |
oneHour()
Create and return a new TimePeriod representing exactly one hour.
|
static TimePeriod |
oneMonth()
Create and return a new TimePeriod representing exactly one month.
|
static TimePeriod |
oneQuarter()
Create and return a new TimePeriod representing one quarter of a year.
|
static TimePeriod |
oneSecond()
Create and return a new TimePeriod representing one second.
|
static TimePeriod |
oneTenthSecond()
Create and return a new TimePeriod representing one tenth of a second.
|
static TimePeriod |
oneWeek()
Create and return a new TimePeriod representing one week.
|
static TimePeriod |
oneYear()
Create and return a new TimePeriod representing exactly one year.
|
long |
periodLength()
The length of this time period relative to the underlying time unit.
|
TimeUnit |
timeUnit()
The unit of time underlying this time period.
|
String |
toString() |
double |
totalSeconds()
The total amount of time in this time period measured in seconds, the base SI unit of time.
|
static TimePeriod |
triAnnual()
Create and return a new TimePeriod representing one third of a year.
|
static TimePeriod |
twoYears()
Create and return a new TimePeriod representing exactly two years.
|
long |
unitLength()
The length of this time period expressed in terms of its underlying time unit.
|
public TimePeriod(TimeUnit timeUnit, long periodLength)
timeUnit - the unit of time underlying this time periodperiodLength - the length of this time period relative to the given unit of time. Note that the
period length must be a long. Most decimal time periods can be modeled by
converting to an appropriate time unit with a smaller order of magnitude. For example, the
halfMonth() constructor works by converting
15.2184375 days to 1314873 seconds.IllegalArgumentException - if the given period length is less than or equal to 0.public static TimePeriod oneHour()
public static TimePeriod oneYear()
public static TimePeriod twoYears()
public static TimePeriod halfDecade()
public static TimePeriod oneMonth()
public static TimePeriod halfMonth()
public static TimePeriod oneQuarter()
public static TimePeriod oneWeek()
public static TimePeriod oneDay()
public static TimePeriod halfYear()
public static TimePeriod oneDecade()
public static TimePeriod halfCentury()
public static TimePeriod oneCentury()
public static TimePeriod halfHour()
public static TimePeriod halfDay()
public static TimePeriod triAnnual()
public static TimePeriod oneSecond()
public static TimePeriod halfSecond()
public static TimePeriod oneTenthSecond()
public TimeUnit timeUnit()
public long periodLength()
public long unitLength()
public double frequencyPer(TimePeriod otherTimePeriod)
For example, if this time period is a month and the given time period is half a year, the return value is 6 since a month occurs 6 times in one year.
otherTimePeriod - the time period for which the frequency of occurrence of this time period is to be found.public double totalSeconds()