Class GJChronology.CutoverField
- java.lang.Object
-
- org.joda.time.DateTimeField
-
- org.joda.time.field.BaseDateTimeField
-
- org.joda.time.chrono.GJChronology.CutoverField
-
- Direct Known Subclasses:
GJChronology.ImpreciseCutoverField
- Enclosing class:
- GJChronology
private class GJChronology.CutoverField extends BaseDateTimeField
This basic cutover field adjusts calls to 'get' and 'set' methods, and assumes that calls to add and addWrapField are unaffected by the cutover.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) booleaniConvertByWeekyear(package private) longiCutoverprotected DurationFieldiDurationField(package private) DateTimeFieldiGregorianField(package private) DateTimeFieldiJulianFieldprotected DurationFieldiRangeDurationFieldprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description CutoverField(DateTimeField julianField, DateTimeField gregorianField, long cutoverMillis)CutoverField(DateTimeField julianField, DateTimeField gregorianField, long cutoverMillis, boolean convertByWeekyear)CutoverField(DateTimeField julianField, DateTimeField gregorianField, DurationField rangeField, long cutoverMillis, boolean convertByWeekyear)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longadd(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.int[]add(ReadablePartial partial, int fieldIndex, int[] values, int valueToAdd)Adds a value (which may be negative) to the partial instant, throwing an exception if the maximum size of the instant is reached.intget(long instant)Get the value of this field from the milliseconds.java.lang.StringgetAsShortText(int fieldValue, java.util.Locale locale)Get the human-readable, short text value of this field from the field value.java.lang.StringgetAsShortText(long instant, java.util.Locale locale)Get the human-readable, short text value of this field from the milliseconds.java.lang.StringgetAsText(int fieldValue, java.util.Locale locale)Get the human-readable, text value of this field from the field value.java.lang.StringgetAsText(long instant, java.util.Locale locale)Get the human-readable, text 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.DurationFieldgetDurationField()Returns the duration per unit value of this field.intgetLeapAmount(long instant)Gets the amount by which this field is 'leap' for the specified instant.DurationFieldgetLeapDurationField()If this field were to leap, then it would be in units described by the returned duration.intgetMaximumShortTextLength(java.util.Locale locale)Get the maximum short text value for this field.intgetMaximumTextLength(java.util.Locale locale)Get the maximum text value for this field.intgetMaximumValue()Get the maximum allowable value for this field.intgetMaximumValue(long instant)Get the maximum value for this field evaluated at the specified time.intgetMaximumValue(ReadablePartial partial)Get the maximum value for this field evaluated at the specified instant.intgetMaximumValue(ReadablePartial partial, int[] values)Get the maximum value for this field using the partial instant and the specified values.intgetMinimumValue()Get the minimum allowable value for this field.intgetMinimumValue(long instant)Get the minimum value for this field evaluated at the specified time.intgetMinimumValue(ReadablePartial partial)Get the minimum value for this field evaluated at the specified instant.intgetMinimumValue(ReadablePartial partial, int[] values)Get the minimum value for this field using the partial instant and the specified values.DurationFieldgetRangeDurationField()Returns the range duration of this field.protected longgregorianToJulian(long instant)booleanisLeap(long instant)Returns whether this field is 'leap' for the specified instant.booleanisLenient()Returns true if the set method is lenient.protected longjulianToGregorian(long instant)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 value)Sets a value in the milliseconds supplied.longset(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
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
-
iJulianField
final DateTimeField iJulianField
-
iGregorianField
final DateTimeField iGregorianField
-
iCutover
final long iCutover
-
iConvertByWeekyear
final boolean iConvertByWeekyear
-
iDurationField
protected DurationField iDurationField
-
iRangeDurationField
protected DurationField iRangeDurationField
-
-
Constructor Detail
-
CutoverField
CutoverField(DateTimeField julianField, DateTimeField gregorianField, long cutoverMillis)
- Parameters:
julianField- field from the chronology used before the cutover instantgregorianField- field from the chronology used at and after the cutovercutoverMillis- the millis of the cutover
-
CutoverField
CutoverField(DateTimeField julianField, DateTimeField gregorianField, long cutoverMillis, boolean convertByWeekyear)
- Parameters:
julianField- field from the chronology used before the cutover instantgregorianField- field from the chronology used at and after the cutovercutoverMillis- the millis of the cutoverconvertByWeekyear-
-
CutoverField
CutoverField(DateTimeField julianField, DateTimeField gregorianField, DurationField rangeField, long cutoverMillis, boolean convertByWeekyear)
- Parameters:
julianField- field from the chronology used before the cutover instantgregorianField- field from the chronology used at and after the cutoverrangeField- the range fieldcutoverMillis- the millis of the cutoverconvertByWeekyear-
-
-
Method Detail
-
isLenient
public boolean isLenient()
Description copied from class:DateTimeFieldReturns 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:
isLenientin classDateTimeField- Returns:
- true if this field is lenient
-
get
public int get(long instant)
Description copied from class:BaseDateTimeFieldGet the value of this field from the milliseconds.- Specified by:
getin classBaseDateTimeField- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Z to query- Returns:
- the value of the field, in the units of the field
-
getAsText
public java.lang.String getAsText(long instant, java.util.Locale locale)Description copied from class:BaseDateTimeFieldGet the human-readable, text value of this field from the milliseconds. If the specified locale is null, the default locale is used.The default implementation returns getAsText(get(instant), locale).
- Overrides:
getAsTextin classBaseDateTimeField- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Z to querylocale- the locale to use for selecting a text symbol, null means default- Returns:
- the text value of the field
-
getAsText
public java.lang.String getAsText(int fieldValue, java.util.Locale locale)Description copied from class:BaseDateTimeFieldGet 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:
getAsTextin 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
-
getAsShortText
public java.lang.String getAsShortText(long instant, java.util.Locale locale)Description copied from class:BaseDateTimeFieldGet the human-readable, short text value of this field from the milliseconds. If the specified locale is null, the default locale is used.The default implementation returns getAsShortText(get(instant), locale).
- Overrides:
getAsShortTextin classBaseDateTimeField- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Z to querylocale- the locale to use for selecting a text symbol, null means default- Returns:
- the text value of the field
-
getAsShortText
public java.lang.String getAsShortText(int fieldValue, java.util.Locale locale)Description copied from class:BaseDateTimeFieldGet the human-readable, short text value of this field from the field value. If the specified locale is null, the default locale is used.The default implementation returns getAsText(fieldValue, locale).
Note: subclasses that override this method should also override getMaximumShortTextLength.
- Overrides:
getAsShortTextin 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
-
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 classBaseDateTimeField- 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 classBaseDateTimeField- 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)
-
add
public int[] add(ReadablePartial partial, int fieldIndex, int[] values, int valueToAdd)
Description copied from class:BaseDateTimeFieldAdds a value (which may be negative) to the partial instant, throwing an exception if the maximum size of the instant is reached.The value will be added to this field, overflowing into larger fields if necessary. 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.
Partial instants only contain some fields. This may result in a maximum possible value, such as TimeOfDay being limited to 23:59:59:999. If this limit is breached by the add an exception is thrown.
For example, in the ISO chronology:
2000-08-20 add six months is 2000-02-20
2000-08-20 add twenty months is 2000-04-20
2000-08-20 add minus nine months is 2000-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:
partial- the partial instantfieldIndex- the index of this field in the partialvalues- the values of the partial instant which should be updatedvalueToAdd- 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 value)Description copied from class:BaseDateTimeFieldSets a value in the milliseconds supplied.The value of this field will be set. If the value is invalid, an exception if thrown.
If setting this field would make other fields invalid, then those fields may be changed. For example if the current date is the 31st January, and the month is set to February, the day would be invalid. Instead, the day would be changed to the closest value - the 28th/29th February as appropriate.
- Specified by:
setin classBaseDateTimeField- Parameters:
instant- the milliseconds from 1970-01-01T00:00:00Z to set invalue- the value to set, in the units of the field- Returns:
- the updated milliseconds
-
set
public long set(long instant, java.lang.String text, java.util.Locale locale)Description copied from class:BaseDateTimeFieldSets 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:
setin 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
-
getDurationField
public DurationField getDurationField()
Description copied from class:BaseDateTimeFieldReturns 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:
getDurationFieldin classBaseDateTimeField- Returns:
- the duration of this field, or UnsupportedDurationField if field has no duration
-
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.- Specified by:
getRangeDurationFieldin classBaseDateTimeField- Returns:
- the range duration of this field, or null if field has no range
-
isLeap
public boolean isLeap(long instant)
Description copied from class:BaseDateTimeFieldReturns whether this field is 'leap' for the specified instant.For example, a leap year would return true, a non leap year would return false.
This implementation returns false.
- Overrides:
isLeapin classBaseDateTimeField- Parameters:
instant- the instant to check for leap status- Returns:
- true if the field is 'leap'
-
getLeapAmount
public int getLeapAmount(long instant)
Description copied from class:BaseDateTimeFieldGets the amount by which this field is 'leap' for the specified instant.For example, a leap year would return one, a non leap year would return zero.
This implementation returns zero.
- Overrides:
getLeapAmountin classBaseDateTimeField- Parameters:
instant- the instant to check for leap status- Returns:
- the amount, in units of the leap duration field, that the field is leap
-
getLeapDurationField
public DurationField getLeapDurationField()
Description copied from class:BaseDateTimeFieldIf this field were to leap, then it would be in units described by the returned duration. If this field doesn't ever leap, null is returned.This implementation returns null.
- Overrides:
getLeapDurationFieldin classBaseDateTimeField- Returns:
- the leap duration field if field can be leap, null if it can't
-
getMinimumValue
public int getMinimumValue()
Description copied from class:BaseDateTimeFieldGet the minimum allowable value for this field.- Specified by:
getMinimumValuein classBaseDateTimeField- Returns:
- the minimum valid value for this field, in the units of the field
-
getMinimumValue
public int getMinimumValue(ReadablePartial partial)
Description copied from class:BaseDateTimeFieldGet the minimum value for this field evaluated at the specified instant.This implementation returns the same as
BaseDateTimeField.getMinimumValue().- Overrides:
getMinimumValuein classBaseDateTimeField- Parameters:
partial- the partial instant to query- Returns:
- the minimum value for this field, in the units of the field
-
getMinimumValue
public int getMinimumValue(ReadablePartial partial, int[] values)
Description copied from class:BaseDateTimeFieldGet the minimum value for this field using the partial instant and the specified values.This implementation returns the same as
BaseDateTimeField.getMinimumValue(ReadablePartial).- Overrides:
getMinimumValuein classBaseDateTimeField- Parameters:
partial- the partial instant to queryvalues- the values to use- Returns:
- the minimum value for this field, in the units of the 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 classBaseDateTimeField- 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()
Description copied from class:BaseDateTimeFieldGet the maximum allowable value for this field.- Specified by:
getMaximumValuein classBaseDateTimeField- Returns:
- the maximum valid 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 classBaseDateTimeField- 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
-
getMaximumValue
public int getMaximumValue(ReadablePartial partial)
Description copied from class:BaseDateTimeFieldGet the maximum value for this field evaluated at the specified instant.This implementation returns the same as
BaseDateTimeField.getMaximumValue().- Overrides:
getMaximumValuein classBaseDateTimeField- Parameters:
partial- the partial instant to query- Returns:
- the maximum value for this field, in the units of the field
-
getMaximumValue
public int getMaximumValue(ReadablePartial partial, int[] values)
Description copied from class:BaseDateTimeFieldGet the maximum value for this field using the partial instant and the specified values.This implementation returns the same as
BaseDateTimeField.getMaximumValue(ReadablePartial).- Overrides:
getMaximumValuein classBaseDateTimeField- Parameters:
partial- the partial instant to queryvalues- the values to use- Returns:
- the maximum 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.
- Specified by:
roundFloorin 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: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
-
getMaximumTextLength
public int getMaximumTextLength(java.util.Locale locale)
Description copied from class:BaseDateTimeFieldGet the maximum text value for this field. The default implementation returns the equivalent of Integer.toString(getMaximumValue()).length().- Overrides:
getMaximumTextLengthin classBaseDateTimeField- Parameters:
locale- the locale to use for selecting a text symbol- Returns:
- the maximum text length
-
getMaximumShortTextLength
public int getMaximumShortTextLength(java.util.Locale locale)
Description copied from class:BaseDateTimeFieldGet the maximum short text value for this field. The default implementation returns getMaximumTextLength().- Overrides:
getMaximumShortTextLengthin classBaseDateTimeField- Parameters:
locale- the locale to use for selecting a text symbol- Returns:
- the maximum short text length
-
julianToGregorian
protected long julianToGregorian(long instant)
-
gregorianToJulian
protected long gregorianToJulian(long instant)
-
-