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
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
FieldsFields inherited from class org.joda.time.chrono.GJChronology.CutoverField
iConvertByWeekyear, iCutover, iDurationField, iGregorianField, iJulianField, iRangeDurationField -
Constructor Summary
ConstructorsConstructorDescriptionImpreciseCutoverField(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
Modifier and TypeMethodDescriptionlongadd(long instant, int value) Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.longadd(long instant, long value) Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.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(long instant) Get the maximum value for this field evaluated at the specified time.intgetMinimumValue(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, setMethods 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, toStringMethods inherited from class org.joda.time.DateTimeField
setExtended
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
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 Details
-
add
public long add(long instant, int value) 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 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:BaseDateTimeFieldAdds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.- Overrides:
addin 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:
-
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 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: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 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:BaseDateTimeFieldGet the minimum value for this field evaluated at the specified time.This implementation returns the same as
BaseDateTimeField.getMinimumValue().- Overrides:
getMinimumValuein 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:BaseDateTimeFieldGet the maximum value for this field evaluated at the specified time.This implementation returns the same as
BaseDateTimeField.getMaximumValue().- Overrides:
getMaximumValuein 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
-