Class GJYearOfEraDateTimeField
- java.lang.Object
-
- org.joda.time.DateTimeField
-
- org.joda.time.field.BaseDateTimeField
-
- org.joda.time.field.DecoratedDateTimeField
-
- org.joda.time.chrono.GJYearOfEraDateTimeField
-
final class GJYearOfEraDateTimeField extends DecoratedDateTimeField
Provides time calculations for the year of era component of time.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private BasicChronologyiChronologyprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description GJYearOfEraDateTimeField(DateTimeField yearField, BasicChronology chronology)Restricted constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longadd(long instant, int years)Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.longadd(long instant, long years)Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.longaddWrapField(long instant, int years)Adds a value (which may be negative) to the instant value, wrapping within this field.int[]addWrapField(ReadablePartial instant, int fieldIndex, int[] values, int years)Adds a value (which may be negative) to the partial instant, wrapping within this field.intget(long instant)Get the value of this field from the milliseconds.intgetDifference(long minuendInstant, long subtrahendInstant)Computes the difference between two instants, as measured in the units of this field.longgetDifferenceAsLong(long minuendInstant, long subtrahendInstant)Computes the difference between two instants, as measured in the units of this field.intgetMaximumValue()Get the maximum allowable value for this field.intgetMinimumValue()Get the minimum allowable value for this field.DurationFieldgetRangeDurationField()Returns the range duration of this field.private java.lang.ObjectreadResolve()Serialization singletonlongremainder(long instant)Returns the fractional duration milliseconds of this field.longroundCeiling(long instant)Round to the highest whole unit of this field.longroundFloor(long instant)Round to the lowest whole unit of this field.longset(long instant, int year)Set the year component of the specified time instant.-
Methods inherited from class org.joda.time.field.DecoratedDateTimeField
getDurationField, getWrappedField, isLenient
-
Methods inherited from class org.joda.time.field.BaseDateTimeField
add, addWrapPartial, convertText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getAsText, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getType, isLeap, isSupported, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, set, set, toString
-
Methods inherited from class org.joda.time.DateTimeField
setExtended
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
iChronology
private final BasicChronology iChronology
-
-
Constructor Detail
-
GJYearOfEraDateTimeField
GJYearOfEraDateTimeField(DateTimeField yearField, BasicChronology chronology)
Restricted constructor.
-
-
Method Detail
-
getRangeDurationField
public DurationField getRangeDurationField()
Description copied from class:BaseDateTimeFieldReturns the range duration of this field. For example, if this field represents "hour of day", then the range duration is a day.- Overrides:
getRangeDurationFieldin classDecoratedDateTimeField- Returns:
- the range duration of this field, or null if field has no range
-
get
public int get(long instant)
Description copied from class:BaseDateTimeFieldGet the value of this field from the milliseconds.- Overrides:
getin classDecoratedDateTimeField- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Z to query- Returns:
- the value of the field, in the units of the field
-
add
public long add(long instant, int years)Description copied from class:BaseDateTimeFieldAdds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.The value will be added to this field. If the value is too large to be added solely to this field, larger fields will increase as required. Smaller fields should be unaffected, except where the result would be an invalid value for a smaller field. In this case the smaller field is adjusted to be in range.
For example, in the ISO chronology:
2000-08-20 add six months is 2001-02-20
2000-08-20 add twenty months is 2002-04-20
2000-08-20 add minus nine months is 1999-11-20
2001-01-31 add one month is 2001-02-28
2001-01-31 add two months is 2001-03-31- Overrides:
addin classBaseDateTimeField- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Z to add toyears- the value to add, in the units of the field- Returns:
- the updated milliseconds
-
add
public long add(long instant, long years)Description copied from class:BaseDateTimeFieldAdds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.- Overrides:
addin classBaseDateTimeField- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Z to add toyears- the long value to add, in the units of the field- Returns:
- the updated milliseconds
- See Also:
BaseDateTimeField.add(long,int)
-
addWrapField
public long addWrapField(long instant, int years)Description copied from class:BaseDateTimeFieldAdds a value (which may be negative) to the instant value, wrapping within this field.The value will be added to this field. If the value is too large to be added solely to this field then it wraps. Larger fields are always unaffected. Smaller fields should be unaffected, except where the result would be an invalid value for a smaller field. In this case the smaller field is adjusted to be in range.
For example, in the ISO chronology:
2000-08-20 addWrapField six months is 2000-02-20
2000-08-20 addWrapField twenty months is 2000-04-20
2000-08-20 addWrapField minus nine months is 2000-11-20
2001-01-31 addWrapField one month is 2001-02-28
2001-01-31 addWrapField two months is 2001-03-31
The default implementation internally calls set. Subclasses are encouraged to provide a more efficient implementation.
- Overrides:
addWrapFieldin classBaseDateTimeField- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Z to add toyears- the value to add, in the units of the field- Returns:
- the updated milliseconds
-
addWrapField
public int[] addWrapField(ReadablePartial instant, int fieldIndex, int[] values, int years)
Description copied from class:BaseDateTimeFieldAdds a value (which may be negative) to the partial instant, wrapping within this field.The value will be added to this field. If the value is too large to be added solely to this field then it wraps. Larger fields are always unaffected. Smaller fields should be unaffected, except where the result would be an invalid value for a smaller field. In this case the smaller field is adjusted to be in range.
For example, in the ISO chronology:
2000-08-20 addWrapField six months is 2000-02-20
2000-08-20 addWrapField twenty months is 2000-04-20
2000-08-20 addWrapField minus nine months is 2000-11-20
2001-01-31 addWrapField one month is 2001-02-28
2001-01-31 addWrapField two months is 2001-03-31
The default implementation internally calls set. Subclasses are encouraged to provide a more efficient implementation.
- Overrides:
addWrapFieldin classBaseDateTimeField- Parameters:
instant- the partial instantfieldIndex- the index of this field in the instantvalues- the values of the partial instant which should be updatedyears- the value to add, in the units of the field- Returns:
- the passed in values
-
getDifference
public int getDifference(long minuendInstant, long subtrahendInstant)Description copied from class:BaseDateTimeFieldComputes the difference between two instants, as measured in the units of this field. Any fractional units are dropped from the result. Calling getDifference reverses the effect of calling add. In the following code:long instant = ... int v = ... int age = getDifference(add(instant, v), instant);
The value 'age' is the same as the value 'v'.- Overrides:
getDifferencein classBaseDateTimeField- Parameters:
minuendInstant- the milliseconds from 1970-01-01T00:00:00Z to subtract fromsubtrahendInstant- the milliseconds from 1970-01-01T00:00:00Z to subtract off the minuend- Returns:
- the difference in the units of this field
-
getDifferenceAsLong
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant)Description copied from class:BaseDateTimeFieldComputes the difference between two instants, as measured in the units of this field. Any fractional units are dropped from the result. Calling getDifference reverses the effect of calling add. In the following code:long instant = ... long v = ... long age = getDifferenceAsLong(add(instant, v), instant);
The value 'age' is the same as the value 'v'.- Overrides:
getDifferenceAsLongin classBaseDateTimeField- Parameters:
minuendInstant- the milliseconds from 1970-01-01T00:00:00Z to subtract fromsubtrahendInstant- the milliseconds from 1970-01-01T00:00:00Z to subtract off the minuend- Returns:
- the difference in the units of this field
-
set
public long set(long instant, int year)Set the year component of the specified time instant.- Overrides:
setin classDecoratedDateTimeField- Parameters:
instant- the time instant in millis to update.year- the year (0,292278994) to update the time to.- Returns:
- the updated time instant.
- Throws:
java.lang.IllegalArgumentException- if year is invalid.
-
getMinimumValue
public int getMinimumValue()
Description copied from class:BaseDateTimeFieldGet the minimum allowable value for this field.- Overrides:
getMinimumValuein classDecoratedDateTimeField- Returns:
- the minimum valid value for this field, in the units of the field
-
getMaximumValue
public int getMaximumValue()
Description copied from class:BaseDateTimeFieldGet the maximum allowable value for this field.- Overrides:
getMaximumValuein classDecoratedDateTimeField- Returns:
- the maximum valid value for this field, in the units of the field
-
roundFloor
public long roundFloor(long instant)
Description copied from class:BaseDateTimeFieldRound 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.
- Overrides:
roundFloorin classDecoratedDateTimeField- 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:BaseDateTimeFieldRound 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:
roundCeilingin classBaseDateTimeField- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
remainder
public long remainder(long instant)
Description copied from class:BaseDateTimeFieldReturns the fractional duration milliseconds of this field. In other words, calling remainder returns the duration that roundFloor would subtract.For example, on a datetime of 2002-11-02T23:34:56.789, the remainder by hour is 34 minutes and 56.789 seconds.
The default implementation computes
instant - roundFloor(instant). Subclasses are encouraged to provide a more efficient implementation.- Overrides:
remainderin classBaseDateTimeField- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Z to get the remainder- Returns:
- remainder duration, in milliseconds
-
readResolve
private java.lang.Object readResolve()
Serialization singleton
-
-