Package org.joda.time.chrono
Class GJChronology.ImpreciseCutoverField
- java.lang.Object
-
- org.joda.time.DateTimeField
-
- org.joda.time.field.BaseDateTimeField
-
- org.joda.time.chrono.GJChronology.CutoverField
-
- org.joda.time.chrono.GJChronology.ImpreciseCutoverField
-
- Enclosing class:
- GJChronology
private final class GJChronology.ImpreciseCutoverField extends GJChronology.CutoverField
Cutover field for variable length fields. These fields internally call set whenever add is called. As a result, the same correction applied to set must be applied to add and addWrapField. Knowing when to use this field requires specific knowledge of how the GJ fields are implemented.
-
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
-
Fields inherited from class org.joda.time.chrono.GJChronology.CutoverField
iConvertByWeekyear, iCutover, iDurationField, iGregorianField, iJulianField, iRangeDurationField
-
-
Constructor Summary
Constructors Constructor Description ImpreciseCutoverField(DateTimeField julianField, DateTimeField gregorianField, long cutoverMillis)
Creates a duration field that links back to this.ImpreciseCutoverField(DateTimeField julianField, DateTimeField gregorianField, DurationField durationField, long cutoverMillis)
Uses a shared duration field rather than creating a new one.ImpreciseCutoverField(DateTimeField julianField, DateTimeField gregorianField, DurationField durationField, long cutoverMillis, boolean convertByWeekyear)
Uses a shared duration field rather than creating a new one.ImpreciseCutoverField(DateTimeField julianField, DateTimeField gregorianField, DurationField durationField, DurationField rangeDurationField, long cutoverMillis)
Uses shared duration fields rather than creating a new one.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
add(long instant, int value)
Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.long
add(long instant, long value)
Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.int
getDifference(long minuendInstant, long subtrahendInstant)
Computes the difference between two instants, as measured in the units of this field.long
getDifferenceAsLong(long minuendInstant, long subtrahendInstant)
Computes the difference between two instants, as measured in the units of this field.int
getMaximumValue(long instant)
Get the maximum value for this field evaluated at the specified time.int
getMinimumValue(long instant)
Get the minimum value for this field evaluated at the specified time.-
Methods inherited from class org.joda.time.chrono.GJChronology.CutoverField
add, get, getAsShortText, getAsShortText, getAsText, getAsText, getDurationField, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getRangeDurationField, gregorianToJulian, isLeap, isLenient, julianToGregorian, roundCeiling, roundFloor, set, set
-
Methods inherited from class org.joda.time.field.BaseDateTimeField
addWrapField, addWrapField, addWrapPartial, convertText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getName, getType, isSupported, remainder, roundHalfCeiling, roundHalfEven, roundHalfFloor, 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
-
-
Constructor Detail
-
ImpreciseCutoverField
ImpreciseCutoverField(DateTimeField julianField, DateTimeField gregorianField, long cutoverMillis)
Creates a duration field that links back to this.
-
ImpreciseCutoverField
ImpreciseCutoverField(DateTimeField julianField, DateTimeField gregorianField, DurationField durationField, long cutoverMillis)
Uses a shared duration field rather than creating a new one.- Parameters:
durationField
- shared duration field
-
ImpreciseCutoverField
ImpreciseCutoverField(DateTimeField julianField, DateTimeField gregorianField, DurationField durationField, DurationField rangeDurationField, long cutoverMillis)
Uses shared duration fields rather than creating a new one.- Parameters:
durationField
- shared duration field
-
ImpreciseCutoverField
ImpreciseCutoverField(DateTimeField julianField, DateTimeField gregorianField, DurationField durationField, long cutoverMillis, boolean convertByWeekyear)
Uses a shared duration field rather than creating a new one.- Parameters:
durationField
- shared duration field
-
-
Method Detail
-
add
public long add(long instant, int value)
Description copied from class:BaseDateTimeField
Adds 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:
add
in classGJChronology.CutoverField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to add tovalue
- the value to add, in the units of the field- Returns:
- the updated milliseconds
-
add
public long add(long instant, long value)
Description copied from class:BaseDateTimeField
Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.- Overrides:
add
in classGJChronology.CutoverField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to add tovalue
- the long value to add, in the units of the field- Returns:
- the updated milliseconds
- See Also:
BaseDateTimeField.add(long,int)
-
getDifference
public int getDifference(long minuendInstant, long subtrahendInstant)
Description copied from class:BaseDateTimeField
Computes 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:
getDifference
in classGJChronology.CutoverField
- 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:BaseDateTimeField
Computes 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:
getDifferenceAsLong
in classGJChronology.CutoverField
- 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
-
getMinimumValue
public int getMinimumValue(long instant)
Description copied from class:BaseDateTimeField
Get the minimum value for this field evaluated at the specified time.This implementation returns the same as
BaseDateTimeField.getMinimumValue()
.- Overrides:
getMinimumValue
in classGJChronology.CutoverField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to query- Returns:
- the minimum value for this field, in the units of the field
-
getMaximumValue
public int getMaximumValue(long instant)
Description copied from class:BaseDateTimeField
Get the maximum value for this field evaluated at the specified time.This implementation returns the same as
BaseDateTimeField.getMaximumValue()
.- Overrides:
getMaximumValue
in classGJChronology.CutoverField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to query- Returns:
- the maximum value for this field, in the units of the field
-
-