org.joda.time
Class DurationFieldType

java.lang.Object
  extended by org.joda.time.DurationFieldType
All Implemented Interfaces:
Serializable

public abstract class DurationFieldType
extends Object
implements Serializable

Identifies a duration field, such as years or minutes, in a chronology-neutral way.

A duration field type defines the type of the field, such as hours. If does not directly enable any calculations, however it does provide a getField(Chronology) method that returns the actual calculation engine for a particular chronology.

Instances of DurationFieldType are singletons. They can be compared using ==.

If required, you can create your own field, for example a quarters. You must create a subclass of DurationFieldType that defines the field type. This class returns the actual calculation engine from getField(Chronology).

Since:
1.0
Author:
Stephen Colebourne, Brian S O'Neill
See Also:
Serialized Form

Constructor Summary
protected DurationFieldType(String name)
          Constructor.
 
Method Summary
static DurationFieldType centuries()
          Get the centuries field type.
static DurationFieldType days()
          Get the days field type.
static DurationFieldType eras()
          Get the eras field type.
abstract  DurationField getField(Chronology chronology)
          Gets a suitable field for this type from the given Chronology.
 String getName()
          Get the name of the field.
static DurationFieldType halfdays()
          Get the halfdays field type.
static DurationFieldType hours()
          Get the hours field type.
 boolean isSupported(Chronology chronology)
          Checks whether this field supported in the given Chronology.
static DurationFieldType millis()
          Get the millis field type.
static DurationFieldType minutes()
          Get the minutes field type.
static DurationFieldType months()
          Get the months field type.
static DurationFieldType seconds()
          Get the seconds field type.
 String toString()
          Get a suitable debug string.
static DurationFieldType weeks()
          Get the weeks field type.
static DurationFieldType weekyears()
          Get the weekyears field type.
static DurationFieldType years()
          Get the years field type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DurationFieldType

protected DurationFieldType(String name)
Constructor.

Parameters:
name - the name to use, which by convention, are plural.
Method Detail

millis

public static DurationFieldType millis()
Get the millis field type.

Returns:
the DateTimeFieldType constant

seconds

public static DurationFieldType seconds()
Get the seconds field type.

Returns:
the DateTimeFieldType constant

minutes

public static DurationFieldType minutes()
Get the minutes field type.

Returns:
the DateTimeFieldType constant

hours

public static DurationFieldType hours()
Get the hours field type.

Returns:
the DateTimeFieldType constant

halfdays

public static DurationFieldType halfdays()
Get the halfdays field type.

Returns:
the DateTimeFieldType constant

days

public static DurationFieldType days()
Get the days field type.

Returns:
the DateTimeFieldType constant

weeks

public static DurationFieldType weeks()
Get the weeks field type.

Returns:
the DateTimeFieldType constant

weekyears

public static DurationFieldType weekyears()
Get the weekyears field type.

Returns:
the DateTimeFieldType constant

months

public static DurationFieldType months()
Get the months field type.

Returns:
the DateTimeFieldType constant

years

public static DurationFieldType years()
Get the years field type.

Returns:
the DateTimeFieldType constant

centuries

public static DurationFieldType centuries()
Get the centuries field type.

Returns:
the DateTimeFieldType constant

eras

public static DurationFieldType eras()
Get the eras field type.

Returns:
the DateTimeFieldType constant

getName

public String getName()
Get the name of the field. By convention, names are plural.

Returns:
field name

getField

public abstract DurationField getField(Chronology chronology)
Gets a suitable field for this type from the given Chronology.

Parameters:
chronology - the chronology to use, null means ISOChronology in default zone
Returns:
a suitable field

isSupported

public boolean isSupported(Chronology chronology)
Checks whether this field supported in the given Chronology.

Parameters:
chronology - the chronology to use, null means ISOChronology in default zone
Returns:
true if supported

toString

public String toString()
Get a suitable debug string.

Overrides:
toString in class Object
Returns:
debug string


Copyright © 2002-2012 Joda.org. All Rights Reserved.