Class GJEraDateTimeField
- java.lang.Object
-
- org.joda.time.DateTimeField
-
- org.joda.time.field.BaseDateTimeField
-
- org.joda.time.chrono.GJEraDateTimeField
-
final class GJEraDateTimeField extends BaseDateTimeField
Provides time calculations for the era component of time.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private BasicChronology
iChronology
private static long
serialVersionUID
Serialization version
-
Constructor Summary
Constructors Constructor Description GJEraDateTimeField(BasicChronology chronology)
Restricted constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
get(long instant)
Get the Era component of the specified time instant.java.lang.String
getAsText(int fieldValue, java.util.Locale locale)
Get the human-readable, text value of this field from the field value.DurationField
getDurationField()
Returns the duration per unit value of this field.int
getMaximumTextLength(java.util.Locale locale)
Get the maximum text value for this field.int
getMaximumValue()
Get the maximum allowable value for this field.int
getMinimumValue()
Get the minimum allowable value for this field.DurationField
getRangeDurationField()
Returns the range duration of this field.boolean
isLenient()
Returns true if the set method is lenient.private java.lang.Object
readResolve()
Serialization singletonlong
roundCeiling(long instant)
Round to the highest whole unit of this field.long
roundFloor(long instant)
Round to the lowest whole unit of this field.long
roundHalfCeiling(long instant)
Round to the nearest whole unit of this field.long
roundHalfEven(long instant)
Round to the nearest whole unit of this field.long
roundHalfFloor(long instant)
Round to the nearest whole unit of this field.long
set(long instant, int era)
Set the Era component of the specified time instant.long
set(long instant, java.lang.String text, java.util.Locale locale)
Sets a value in the milliseconds supplied from a human-readable, text value.-
Methods inherited from class org.joda.time.field.BaseDateTimeField
add, add, add, addWrapField, addWrapField, addWrapPartial, convertText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getDifference, getDifferenceAsLong, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getType, isLeap, isSupported, remainder, set, set, set, toString
-
Methods inherited from class org.joda.time.DateTimeField
setExtended
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Serialization version- See Also:
- Constant Field Values
-
iChronology
private final BasicChronology iChronology
-
-
Constructor Detail
-
GJEraDateTimeField
GJEraDateTimeField(BasicChronology chronology)
Restricted constructor
-
-
Method Detail
-
isLenient
public boolean isLenient()
Description copied from class:DateTimeField
Returns true if the set method is lenient. If so, it accepts values that are out of bounds. For example, a lenient day of month field accepts 32 for January, converting it to February 1.- Specified by:
isLenient
in classDateTimeField
- Returns:
- true if this field is lenient
-
get
public int get(long instant)
Get the Era component of the specified time instant.- Specified by:
get
in classBaseDateTimeField
- Parameters:
instant
- the time instant in millis to query.- Returns:
- the value of the field, in the units of the field
-
getAsText
public java.lang.String getAsText(int fieldValue, java.util.Locale locale)
Description copied from class:BaseDateTimeField
Get the human-readable, text value of this field from the field value. If the specified locale is null, the default locale is used.The default implementation returns Integer.toString(get(instant)).
Note: subclasses that override this method should also override getMaximumTextLength.
- Overrides:
getAsText
in classBaseDateTimeField
- Parameters:
fieldValue
- the numeric value to convert to textlocale
- the locale to use for selecting a text symbol, null for default- Returns:
- the text value of the field
-
set
public long set(long instant, int era)
Set the Era component of the specified time instant.- Specified by:
set
in classBaseDateTimeField
- Parameters:
instant
- the time instant in millis to update.era
- the era to update the time to.- Returns:
- the updated time instant.
- Throws:
java.lang.IllegalArgumentException
- if era is invalid.
-
set
public long set(long instant, java.lang.String text, java.util.Locale locale)
Description copied from class:BaseDateTimeField
Sets a value in the milliseconds supplied from a human-readable, text value. If the specified locale is null, the default locale is used.This implementation uses
convertText(String, Locale)
andBaseDateTimeField.set(long, int)
.Note: subclasses that override this method should also override getAsText.
- Overrides:
set
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to set intext
- the text value to setlocale
- the locale to use for selecting a text symbol, null for default- Returns:
- the updated milliseconds
-
roundFloor
public long roundFloor(long instant)
Description copied from class:BaseDateTimeField
Round to the lowest whole unit of this field. After rounding, the value of this field and all fields of a higher magnitude are retained. The fractional millis that cannot be expressed in whole increments of this field are set to minimum.For example, a datetime of 2002-11-02T23:34:56.789, rounded to the lowest whole hour is 2002-11-02T23:00:00.000.
- Specified by:
roundFloor
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
roundCeiling
public long roundCeiling(long instant)
Description copied from class:BaseDateTimeField
Round to the highest whole unit of this field. The value of this field and all fields of a higher magnitude may be incremented in order to achieve this result. The fractional millis that cannot be expressed in whole increments of this field are set to minimum.For example, a datetime of 2002-11-02T23:34:56.789, rounded to the highest whole hour is 2002-11-03T00:00:00.000.
The default implementation calls roundFloor, and if the instant is modified as a result, adds one field unit. Subclasses are encouraged to provide a more efficient implementation.
- Overrides:
roundCeiling
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
roundHalfFloor
public long roundHalfFloor(long instant)
Description copied from class:BaseDateTimeField
Round to the nearest whole unit of this field. If the given millisecond value is closer to the floor or is exactly halfway, this function behaves like roundFloor. If the millisecond value is closer to the ceiling, this function behaves like roundCeiling.- Overrides:
roundHalfFloor
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
roundHalfCeiling
public long roundHalfCeiling(long instant)
Description copied from class:BaseDateTimeField
Round to the nearest whole unit of this field. If the given millisecond value is closer to the floor, this function behaves like roundFloor. If the millisecond value is closer to the ceiling or is exactly halfway, this function behaves like roundCeiling.- Overrides:
roundHalfCeiling
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
roundHalfEven
public long roundHalfEven(long instant)
Description copied from class:BaseDateTimeField
Round to the nearest whole unit of this field. If the given millisecond value is closer to the floor, this function behaves like roundFloor. If the millisecond value is closer to the ceiling, this function behaves like roundCeiling.If the millisecond value is exactly halfway between the floor and ceiling, the ceiling is chosen over the floor only if it makes this field's value even.
- Overrides:
roundHalfEven
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
getDurationField
public DurationField getDurationField()
Description copied from class:BaseDateTimeField
Returns the duration per unit value of this field. For example, if this field represents "hour of day", then the unit duration is an hour.- Specified by:
getDurationField
in classBaseDateTimeField
- Returns:
- the duration of this field, or UnsupportedDurationField if field has no duration
-
getRangeDurationField
public DurationField getRangeDurationField()
Description copied from class:BaseDateTimeField
Returns the range duration of this field. For example, if this field represents "hour of day", then the range duration is a day.- Specified by:
getRangeDurationField
in classBaseDateTimeField
- Returns:
- the range duration of this field, or null if field has no range
-
getMinimumValue
public int getMinimumValue()
Description copied from class:BaseDateTimeField
Get the minimum allowable value for this field.- Specified by:
getMinimumValue
in classBaseDateTimeField
- Returns:
- the minimum valid value for this field, in the units of the field
-
getMaximumValue
public int getMaximumValue()
Description copied from class:BaseDateTimeField
Get the maximum allowable value for this field.- Specified by:
getMaximumValue
in classBaseDateTimeField
- Returns:
- the maximum valid value for this field, in the units of the field
-
getMaximumTextLength
public int getMaximumTextLength(java.util.Locale locale)
Description copied from class:BaseDateTimeField
Get the maximum text value for this field. The default implementation returns the equivalent of Integer.toString(getMaximumValue()).length().- Overrides:
getMaximumTextLength
in classBaseDateTimeField
- Parameters:
locale
- the locale to use for selecting a text symbol- Returns:
- the maximum text length
-
readResolve
private java.lang.Object readResolve()
Serialization singleton
-
-