bb.util
Class TimeLength

java.lang.Object
  extended by bb.util.TimeLength

public class TimeLength
extends Object

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).

Author:
Brent Boyer

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 days) in milliseconds.
static long second
          Length of 1 second in milliseconds.
static long week
          Length of a standard week (i.e. exactly 7 days) 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 days) 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

second

public static final long second
Length of 1 second in milliseconds.

See Also:
Constant Field Values

minute

public static final long minute
Length of 1 minute in milliseconds.

See Also:
Constant Field Values

hour

public static final long hour
Length of 1 hour in milliseconds.

See Also:
Constant Field Values

day

public static final long day
Length of a standard day (i.e. 24 hours) in milliseconds.

On a standard day, nothing unusual (time zone change, leap second) happens.

See Also:
dayTzChNeg, dayTzChNeg, dayLeapPos, dayLeapNeg, dayMin, dayMax, Constant Field Values

dayTzChPos

public static final long dayTzChPos
Length of a positive time zone change day in milliseconds. Such days are always 1 hour shorter than a 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.

See Also:
day, dayTzChNeg, dayLeapPos, dayLeapNeg, dayMin, dayMax, Constant Field Values

dayTzChNeg

public static final long dayTzChNeg
Length of a negative time zone change day in milliseconds. Such days are always 1 hour longer than a 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.

See Also:
day, dayTzChNeg, dayLeapPos, dayLeapNeg, dayMin, dayMax, Constant Field Values

dayLeapPos

public static final long dayLeapPos
Length of a positive leap second day in milliseconds. Such days are always 1 second longer than a 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.

See Also:
day, dayTzChNeg, dayTzChNeg, dayLeapNeg, dayMin, dayMax, Constant Field Values

dayLeapNeg

public static final long dayLeapNeg
Length of a negative leap second day in milliseconds. Such days are always 1 second shorter than a 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.

See Also:
day, dayTzChNeg, dayTzChNeg, dayLeapPos, dayMin, dayMax, Constant Field Values

dayMin

public static final long dayMin
Minimum length of a day in milliseconds. The minimum length day occurs when a positive time zone change happens, so this value is simply equal to 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.

See Also:
day, dayTzChNeg, dayTzChNeg, dayLeapPos, dayLeapNeg, dayMax, Constant Field Values

dayMax

public static final long dayMax
Maximum length of a day in milliseconds. The maximum length day occurs when a negative time zone change happens, so this value is simply equal to 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.

See Also:
day, dayTzChNeg, dayTzChNeg, dayLeapPos, dayLeapNeg, dayMin, Constant Field Values

week

public static final long week
Length of a standard week (i.e. exactly 7 days) in milliseconds.

See Also:
Constant Field Values

weekMin

public static final long weekMin
Minimum length of a week in milliseconds. The minimum length week occurs when a positive time zone change happens during the week, so this value is simply equal to (6L *day) + dayTzChPos.

See Also:
Constant Field Values

weekMax

public static final long weekMax
Maximum length of a week in milliseconds. The maximum length week occurs when a negative time zone change happens during the week, so this value is simply equal to (6L *day) + dayTzChNeg.

See Also:
Constant Field Values

month

public static final long month
Length of a standard month (i.e. exactly 30 days) 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.

See Also:
Constant Field Values

year

public static final long year
Length of a standard year (i.e. exactly 365 days) in milliseconds.

Warning: leap years have 366 days, and even standard (365 day) years can have leap seconds added.

See Also:
Constant Field Values
Constructor Detail

TimeLength

private TimeLength()
This private constructor suppresses the default (public) constructor, ensuring non-instantiability.

Method Detail

timeDescription

public static String timeDescription(long time)