javax.time.calendar
Class ISOPeriodUnit

java.lang.Object
  extended by javax.time.calendar.PeriodUnit
      extended by javax.time.calendar.ISOPeriodUnit
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<PeriodUnit>

public final class ISOPeriodUnit
extends PeriodUnit
implements java.io.Serializable

The units of time used by the ISO calendar system, such as 'Days' or 'Minutes'.

ISOPeriodUnit consists of immutable definitions of units of human-scale time. For example, humans typically measure periods of time in units of years, months, days, hours, minutes and seconds. These concepts are defined by instances of this class defined in the chronology classes.

Units are either basic or derived. A derived unit can be converted accurately to another smaller unit. A basic unit is fundamental, and has no smaller representation. For example years are a derived unit consisting of 12 months, where a month is a basic unit.

Other calendar systems should re-use units from here where appropriate. For example, the definition of a day is usually the same in other calendar systems. To be able to re-use a unit, the definition in the other calendar system must match the definition of a unit and all its dependent units.

This class is final, immutable and thread-safe.

Author:
Stephen Colebourne
See Also:
Serialized Form

Field Summary
static PeriodUnit _12_HOURS
          The period unit for twelve hours, as used by AM/PM.
static PeriodUnit _24_HOURS
          The period unit for twenty-four hours, that is often treated as a day.
static PeriodUnit CENTURIES
          The period unit for centuries.
static PeriodUnit DAYS
          The period unit for days.
static PeriodUnit DECADES
          The period unit for decades.
static PeriodUnit ERAS
          The period unit for eras.
static PeriodUnit HOURS
          The period unit for hours.
static PeriodUnit MICROS
          The period unit for microseconds.
static PeriodUnit MILLENNIA
          The period unit for millennia.
static PeriodUnit MILLIS
          The period unit for milliseconds.
static PeriodUnit MINUTES
          The period unit for minutes.
static PeriodUnit MONTHS
          The period unit for months.
static PeriodUnit NANOS
          The period unit for nanoseconds.
static PeriodUnit QUARTERS
          The period unit for quarters of years.
static PeriodUnit SECONDS
          The period unit for seconds.
static PeriodUnit WEEK_BASED_YEARS
          The period unit for week-based-years as defined by ISO-8601.
static PeriodUnit WEEKS
          The period unit for weeks.
static PeriodUnit YEARS
          The period unit for years.
 
Method Summary
 int compareTo(PeriodUnit other)
          Compares this unit to another.
 boolean equals(java.lang.Object obj)
          Checks if this unit is equal to another unit.
 int hashCode()
          A hash code for this unit.
 
Methods inherited from class javax.time.calendar.PeriodUnit
convertEquivalent, convertEquivalent, field, getBaseEquivalent, getBaseEquivalentAmount, getBaseUnit, getDurationEstimate, getName, toEquivalent, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NANOS

public static final PeriodUnit NANOS
The period unit for nanoseconds.

This is a basic unit and has no equivalent period. The estimated duration is 1 nanosecond. This unit does not depends on any other unit.


MICROS

public static final PeriodUnit MICROS
The period unit for microseconds.

The equivalent period and estimated duration is based on 1000 nanoseconds. This unit depends on the Nanos unit and all units that depends on.


MILLIS

public static final PeriodUnit MILLIS
The period unit for milliseconds.

The equivalent period and estimated duration is based on 1,000,000 nanoseconds. This unit depends on the Micros unit and all units that depends on.


SECONDS

public static final PeriodUnit SECONDS
The period unit for seconds.

The equivalent period and estimated duration is based on 1,000,000,000 nanoseconds. This unit depends on the Millis unit and all units that depends on.


MINUTES

public static final PeriodUnit MINUTES
The period unit for minutes.

The equivalent period and estimated duration is based on 60 seconds. This unit depends on the Seconds unit and all units that depends on.


HOURS

public static final PeriodUnit HOURS
The period unit for hours.

The equivalent period and estimated duration is based on 60 minutes. This unit depends on the Minutes unit and all units that depends on.


_12_HOURS

public static final PeriodUnit _12_HOURS
The period unit for twelve hours, as used by AM/PM.

The equivalent period and estimated duration is based on 12 hours. This unit depends on the Hours unit and all units that depends on.


_24_HOURS

public static final PeriodUnit _24_HOURS
The period unit for twenty-four hours, that is often treated as a day.

The period unit defines the concept of a period of exactly 24 hours that is often treated as a day. The unit name of "24Hours" is intended to convey the fact that this is primarily a 24 hour unit that happens to be used as a day unit on occasion. In most scenarios, the standard Days unit is more applicable and accurate.

This class defines two units that could represent a day. This unit, 24Hours, represents a fixed length of exactly 24 hours, allowing it to be converted to seconds, nanoseconds and Duration. By contrast, the Days unit varies in length based on time-zone (daylight savings time) changes and cannot be converted to seconds, nanoseconds or Duration.

The equivalent period and estimated duration is based on 24 hours. This unit depends on the 12Hours unit and all units that depends on.


DAYS

public static final PeriodUnit DAYS
The period unit for days.

The period unit defines the concept of a period of a day. This is typically equal to 24 hours, but may vary due to time-zone changes.

This class defines two units that could represent a day. This unit, Days, represents a day that varies in length based on time-zone (daylight savings time) changes. It is a basic unit that cannot be converted to seconds, nanoseconds or Duration. By contrast, the 24Hours unit has a fixed length of exactly 24 hours allowing it to be converted to seconds, nanoseconds and Duration.

This is a basic unit and has no equivalent period. The estimated duration is equal to 24 hours. This unit does not depends on any other unit.


WEEKS

public static final PeriodUnit WEEKS
The period unit for weeks.

The equivalent period and estimated duration is based on 7 days. This unit depends on the Days unit and all units that depends on.


MONTHS

public static final PeriodUnit MONTHS
The period unit for months. This is typically 28 to 31 days.

This is a basic unit and has no equivalent period. The estimated duration is equal to one-twelfth of a year based on 365.2425 days. This unit does not depend on any other unit.


QUARTERS

public static final PeriodUnit QUARTERS
The period unit for quarters of years.

The equivalent period and estimated duration is based on 3 months. This unit depends on the Months unit and all units that depends on.


WEEK_BASED_YEARS

public static final PeriodUnit WEEK_BASED_YEARS
The period unit for week-based-years as defined by ISO-8601. This is typically 52 weeks, and occasionally 53 weeks.

This is a basic unit and has no equivalent period. The estimated duration is equal to 364.5 days, which is just over 52 weeks. This unit does not depend on any other unit.


YEARS

public static final PeriodUnit YEARS
The period unit for years.

The equivalent period and estimated duration is based on 12 months based on 365.2425 days. This unit depends on the Quarters unit and all units that depends on.


DECADES

public static final PeriodUnit DECADES
The period unit for decades.

The equivalent period and estimated duration is based on 10 years. This unit depends on the Years unit and all units that depends on.


CENTURIES

public static final PeriodUnit CENTURIES
The period unit for centuries.

The equivalent period and estimated duration is based on 100 years. This unit depends on the Decades unit and all units that depends on.


MILLENNIA

public static final PeriodUnit MILLENNIA
The period unit for millennia.

The equivalent period and estimated duration is based on 1000 years. This unit depends on the Centuries unit and all units that depends on.


ERAS

public static final PeriodUnit ERAS
The period unit for eras.

This represents an era based on a simple before/after point on the time-line. Such an era is infinite in length. For this rule, an era has an estimated duration of 2,000,000,000 years.

This is a basic unit and has no equivalent period. The estimated duration is equal to 2,000,000,000 years. This unit does not depend on any other unit.

Method Detail

compareTo

public int compareTo(PeriodUnit other)
Description copied from class: PeriodUnit
Compares this unit to another.

The comparison is based primarily on the estimated duration. If that is equal, the name is compared using standard string comparison. Then the base units are compared, followed by the base equivalent period.

Specified by:
compareTo in interface java.lang.Comparable<PeriodUnit>
Overrides:
compareTo in class PeriodUnit
Parameters:
other - the other type to compare to, not null
Returns:
the comparator result, negative if less, positive if greater, zero if equal

equals

public boolean equals(java.lang.Object obj)
Description copied from class: PeriodUnit
Checks if this unit is equal to another unit.

The comparison is based on the name, estimated duration, base unit and base equivalent period.

Overrides:
equals in class PeriodUnit
Parameters:
obj - the object to check, null returns false
Returns:
true if this is equal to the other unit

hashCode

public int hashCode()
Description copied from class: PeriodUnit
A hash code for this unit.

Overrides:
hashCode in class PeriodUnit
Returns:
a suitable hash code