edu.nrao.sss.measure
Enum TimeUnits

java.lang.Object
  extended by java.lang.Enum<TimeUnits>
      extended by edu.nrao.sss.measure.TimeUnits
All Implemented Interfaces:
Symbolic, Serializable, Comparable<TimeUnits>

public enum TimeUnits
extends Enum<TimeUnits>
implements Symbolic

Units of time.

This class enumerates those units of time that are well defined. The unit month, for example, is not considered to be well-defined because sometimes it is 28 days, sometimes 29, and so on.

Table of Units

Element Name(s)1 Symbol(s)1 Seconds
MICROSECONDMICROSECOND µs10-6
MILLISECONDMILLISECOND ms0.001
SECONDSECOND s1.0
MINUTEMINUTE m60.0
HOURHOUR h3,600.0
DAYDAY d86,400.0
YEARYEAR y31,556,925.18748800
1The names in these columns may be sent to fromString(String). Note that the names are not case sensitive.

Table of Conversion Factors2

nsµsmssmhdwtyy
NANOSECOND10.0010.0000011E-91.66666666666666666666666666666666666666666666666666666666666666666666666666666666666666667E-112.777777777777777777777777777777777777777777777777777777777777777777777777777777777777778E-131.15740740740740740740740740740740740740740740740740740740740740740740740740740740740741E-141.6534391534391534391534391534391534391534391534391534391534391534391534391534391534392E-153.16887653663353660911395687389964307585456367629474904594101671868225683971378495887E-17
MICROSECOND1E+310.0010.0000011.66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667E-82.777777777777777777777777777777777777777777777777777777777777777777777777777777777777777778E-101.15740740740740740740740740740740740740740740740740740740740740740740740740740740740740741E-111.6534391534391534391534391534391534391534391534391534391534391534391534391534391534391534E-123.16887653663353660911395687389964307585456367629474904594101671868225683971378495887162E-14
MILLISECOND1E+61E+310.0010.00001666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666672.777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777778E-71.15740740740740740740740740740740740740740740740740740740740740740740740740740740740740740741E-81.6534391534391534391534391534391534391534391534391534391534391534391534391534391534391534392E-93.16887653663353660911395687389964307585456367629474904594101671868225683971378495887162299E-11
SECOND1E+91E+61E+310.01666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666670.00027777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777780.00001157407407407407407407407407407407407407407407407407407407407407407407407407407407407407407407410.00000165343915343915343915343915343915343915343915343915343915343915343915343915343915343915343915343.16887653663353660911395687389964307585456367629474904594101671868225683971378495887162298978E-8
MINUTE6E+106E+76E+46E+110.01666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666670.00069444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444440.00009920634920634920634920634920634920634920634920634920634920634920634920634920634920634920634920630.0000019013259219801219654683741243397858455127382057768494275646100312093541038282709753229737938657
HOUR3.6E+123.6E+93.6E+63.6E+36E+110.04166666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666670.0059523809523809523809523809523809523809523809523809523809523809523809523809523809523809523809523810.0001140795553188073179281024474603871507307642923466109656538766018725612462296962585193784276319423
DAY8.64E+138.64E+108.64E+78.64E+41.44E+32410.14285714285714285714285714285714285714285714285714285714285714285714285714285714285714285714285714290.0027379093276513756302744587390492916175383430163186631756930384449414699095127102044650822631666143
WEEK6.048E+146.048E+116.048E+86.048E+51.008E+4168710.0191653652935596294119212111733450413227684011142306422298512691145902893665889714312555758421662999
YEAR3.15569252522016E+1631556925252201.631556925252.201631556925.2522016525948.754203368765.812570056365.24219041952.17745577414285714285714285714285714285714285714285714285714285714285714285714285714285714285714285711
2This table was generated from the conversion logic of this class.

Version Info:

$Revision: 1725 $
$Date: 2008-11-20 15:40:30 -0700 (Thu, 20 Nov 2008) $
$Author: switz $

Since:
2006-03-23
Author:
David M. Harland

Enum Constant Summary
DAY
          One day, or 24 hours.
HOUR
          One hour, or 60 minutes.
MICROSECOND
          One millionth of a second.
MILLISECOND
          One thousandth of a second.
MINUTE
          One minute, or 60 seconds.
NANOSECOND
          One billionth of a second.
SECOND
          One second.
TROPICAL_YEAR
          Deprecated. Same as YEAR.
WEEK
          One week, or 7 days.
YEAR
          A tropical, as opposed to sidereal (or any other kind of), year.
 
Method Summary
static TimeUnits fromString(String text)
          Returns the time units represented by text.
static TimeUnits getDefault()
          Returns a default unit of time.
 String getSymbol()
          Returns the symbol for this unit.
 boolean symbolsAreCaseSensitive()
          Returns false -- these symbols are not case sensitive.
 BigDecimal toSeconds()
          Returns the number of seconds in one of these units.
 String toString()
          Returns a text representation of this enumeration constant.
 BigDecimal toUnits(TimeUnits otherUnits)
          Returns a factor for converting from this unit to otherUnits.
static TimeUnits valueOf(String name)
          Returns the enum constant of this type with the specified name.
static TimeUnits[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

TROPICAL_YEAR

@Deprecated
public static final TimeUnits TROPICAL_YEAR
Deprecated. Same as YEAR.

YEAR

public static final TimeUnits YEAR
A tropical, as opposed to sidereal (or any other kind of), year.

The length of this year is taken as the J2000 value of 365.242 189 670 SI days. See Wikipedia for more information.


WEEK

public static final TimeUnits WEEK
One week, or 7 days.


DAY

public static final TimeUnits DAY
One day, or 24 hours.

Note that this is one SI day, or one that does not vary with the earth's rotation and that never includes a leap second. It is exactly equal to 86,400.0 SI seconds.


HOUR

public static final TimeUnits HOUR
One hour, or 60 minutes.


MINUTE

public static final TimeUnits MINUTE
One minute, or 60 seconds.


SECOND

public static final TimeUnits SECOND
One second.


MILLISECOND

public static final TimeUnits MILLISECOND
One thousandth of a second.


MICROSECOND

public static final TimeUnits MICROSECOND
One millionth of a second.


NANOSECOND

public static final TimeUnits NANOSECOND
One billionth of a second.

Method Detail

values

public static TimeUnits[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (TimeUnits c : TimeUnits.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static TimeUnits valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

symbolsAreCaseSensitive

public boolean symbolsAreCaseSensitive()
Returns false -- these symbols are not case sensitive.

Specified by:
symbolsAreCaseSensitive in interface Symbolic
Returns:
true if the case of the symbols carry meaning.

getSymbol

public String getSymbol()
Returns the symbol for this unit. For example, the symbol for MILLISECOND is ms.

Specified by:
getSymbol in interface Symbolic
Returns:
the symbol for this unit.

toSeconds

public BigDecimal toSeconds()
Returns the number of seconds in one of these units.

Returns:
the number of seconds in one of these units.

toUnits

public BigDecimal toUnits(TimeUnits otherUnits)
Returns a factor for converting from this unit to otherUnits.

Parameters:
otherUnits - the unit to which conversion is desired.
Returns:
a factor for converting from this unit to otherUnits.

getDefault

public static TimeUnits getDefault()
Returns a default unit of time.

Returns:
a default unit of time.

toString

public String toString()
Returns a text representation of this enumeration constant.

Overrides:
toString in class Enum<TimeUnits>
Returns:
a text representation of this enumeration constant.

fromString

public static TimeUnits fromString(String text)
Returns the time units represented by text.

For details about the transformation, see EnumerationUtility.enumFromString(Class, String).

Parameters:
text - a text representation of a unit of time.
Returns:
the time units represented by text.


Copyright © 2009. All Rights Reserved.