|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.util.TimeLength
public class TimeLength
Provides fields and methods related to lengths of some common periods of time.
Every field or method parameter that is a time value is a long, and has the same units of milliseconds,
making them conform with the usual type and units used for time in Java
(e.g. Date
, System.currentTimeMillis
, etc).
This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).
Field Summary | |
---|---|
static long |
day
Length of a standard day (i.e. 24 hours) in milliseconds. |
static long |
dayLeapNeg
Length of a negative leap second day in milliseconds. |
static long |
dayLeapPos
Length of a positive leap second day in milliseconds. |
static long |
dayMax
Maximum length of a day in milliseconds. |
static long |
dayMin
Minimum length of a day in milliseconds. |
static long |
dayTzChNeg
Length of a negative time zone change day in milliseconds. |
static long |
dayTzChPos
Length of a positive time zone change day in milliseconds. |
static long |
hour
Length of 1 hour in milliseconds. |
static long |
minute
Length of 1 minute in milliseconds. |
static long |
month
Length of a standard month (i.e. exactly 30 day s) in milliseconds. |
static long |
second
Length of 1 second in milliseconds. |
static long |
week
Length of a standard week (i.e. exactly 7 day s) in milliseconds. |
static long |
weekMax
Maximum length of a week in milliseconds. |
static long |
weekMin
Minimum length of a week in milliseconds. |
static long |
year
Length of a standard year (i.e. exactly 365 day s) in milliseconds. |
Constructor Summary | |
---|---|
private |
TimeLength()
This private constructor suppresses the default (public) constructor, ensuring non-instantiability. |
Method Summary | |
---|---|
static String |
timeDescription(long time)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long second
public static final long minute
public static final long hour
public static final long day
On a standard day, nothing unusual (time zone change, leap second) happens.
dayTzChNeg
,
dayTzChNeg
,
dayLeapPos
,
dayLeapNeg
,
dayMin
,
dayMax
,
Constant Field Valuespublic static final long dayTzChPos
standard day
.
Here, "positive time zone change day" means that the time of day was set forward by 1 hour at some point (usually at 1 or 2am).
For such a day, the DateUtil.getAmountTimeZoneChange
method returns 1.
Note: this class assumes that on a time zone change day, nothing else unusual (e.g. a leap second) happens.
day
,
dayTzChNeg
,
dayLeapPos
,
dayLeapNeg
,
dayMin
,
dayMax
,
Constant Field Valuespublic static final long dayTzChNeg
standard day
.
Here, "negative time zone change day" means that the time of day was set back by 1 hour at some point (usually at 1 or 2am).
For such a day, the DateUtil.getAmountTimeZoneChange
method returns -1.
Note: this class assumes that on a time zone change day, nothing else unusual (e.g. a leap second) happens.
day
,
dayTzChNeg
,
dayLeapPos
,
dayLeapNeg
,
dayMin
,
dayMax
,
Constant Field Valuespublic static final long dayLeapPos
standard day
.
Here, "positive leap second day" means that the last minute of the day has 1 extra second
(its second count goes to 60 instead of the usual value of 59).
For such a day, the DateUtil.getLeapSecond
method returns +1
(assuming that the underlying platform supports leap seconds).
Note: leap seconds only occur on December 31 or June 30 of some years;
see Date
or DateUtil
for more discussion.
Note: this class assumes that on a leap second day, nothing else unusual (e.g. a time zone change) happens. This is currently true of the USA and (most of?) Europe, but may possibly not be true for some locality or in the future.
day
,
dayTzChNeg
,
dayTzChNeg
,
dayLeapNeg
,
dayMin
,
dayMax
,
Constant Field Valuespublic static final long dayLeapNeg
standard day
.
Here, "negative leap second day" means that the last minute of the day has 1 less second
(its second count goes to 58 instead of the usual value of 59).
For such a day, the DateUtil.getLeapSecond
method returns -1
(assuming that the underlying platform supports leap seconds).
Note: leap seconds only occur on December 31 or June 30 of some years;
see Date
or DateUtil
for more discussion.
As of 2005/3/23, there has never been a negative leap second day.
Note: this class assumes that on a leap second day, nothing else unusual (e.g. a time zone change) happens. This is currently true of the USA and (most of?) Europe, but may possibly not be true for some locality or in the future.
day
,
dayTzChNeg
,
dayTzChNeg
,
dayLeapPos
,
dayMin
,
dayMax
,
Constant Field Valuespublic static final long dayMin
dayTzChNeg
.
This variable was introduced solely to aid code readability where it is the minimum length of a day that is important, as opposed to any time zone change.
day
,
dayTzChNeg
,
dayTzChNeg
,
dayLeapPos
,
dayLeapNeg
,
dayMax
,
Constant Field Valuespublic static final long dayMax
dayTzChNeg
.
This variable was introduced solely to aid code readability where it is the maximum length of a day that is important, as opposed to any time zone change.
day
,
dayTzChNeg
,
dayTzChNeg
,
dayLeapPos
,
dayLeapNeg
,
dayMin
,
Constant Field Valuespublic static final long week
day
s) in milliseconds.
public static final long weekMin
(6L *day
) + dayTzChPos
.
public static final long weekMax
(6L *day
) + dayTzChNeg
.
public static final long month
day
s) in milliseconds.
Warning: the only actual months which have this standard length are April, June, September, November; all the other months, which are the majority, are "non-standard" and have different lengths.
public static final long year
day
s) in milliseconds.
Warning: leap years have 366 days, and even standard (365 day) years can have leap seconds added.
Constructor Detail |
---|
private TimeLength()
Method Detail |
---|
public static String timeDescription(long time)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |