class BasicMonthOfYearDateTimeField extends ImpreciseDateTimeField
Modifier and Type | Field and Description |
---|---|
private BasicChronology |
iChronology |
private int |
iLeapMonth |
private int |
iMax |
private static int |
MIN |
private static long |
serialVersionUID
Serialization version
|
Constructor and Description |
---|
BasicMonthOfYearDateTimeField(BasicChronology chronology,
int leapMonth)
Restricted constructor.
|
Modifier and Type | Method and Description |
---|---|
long |
add(long instant,
int months)
Add the specified month to the specified time instant.
|
long |
add(long instant,
long months)
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.
|
long |
addWrapField(long instant,
int months)
Add to the Month component of the specified time instant
wrapping around within that component if necessary.
|
int |
get(long instant)
Get the Month component of the specified time instant.
|
long |
getDifferenceAsLong(long minuendInstant,
long subtrahendInstant)
Computes the difference between two instants, as measured in the units
of this field.
|
int |
getLeapAmount(long instant)
Gets the amount by which this field is 'leap' for the specified instant.
|
DurationField |
getLeapDurationField()
If this field were to leap, then it would be in units described by the
returned duration.
|
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 |
isLeap(long instant)
Returns whether this field is 'leap' for the specified instant.
|
boolean |
isLenient()
Returns true if the set method is lenient.
|
private java.lang.Object |
readResolve()
Serialization singleton
|
long |
remainder(long instant)
Returns the fractional duration milliseconds of this field.
|
long |
roundFloor(long instant)
Round to the lowest whole unit of this field.
|
long |
set(long instant,
int month)
Set the Month component of the specified time instant.
|
getDifference, getDurationField, getDurationUnitMillis
addWrapField, addWrapPartial, convertText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getAsText, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getType, isSupported, roundCeiling, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, set, set, toString
setExtended
private static final long serialVersionUID
private static final int MIN
private final BasicChronology iChronology
private final int iMax
private final int iLeapMonth
BasicMonthOfYearDateTimeField(BasicChronology chronology, int leapMonth)
leapMonth
- the month of year that leapspublic boolean isLenient()
DateTimeField
isLenient
in class DateTimeField
public int get(long instant)
get
in class ImpreciseDateTimeField
instant
- the time instant in millis to query.DateTimeField.get(long)
,
ReadableDateTime.getMonthOfYear()
public long add(long instant, int months)
If the new month has less total days than the specified day of the month, this value is coerced to the nearest sane value. e.g.
07-31 - (1 month) = 06-30
03-31 - (1 month) = 02-28 or 02-29 depending
add
in class ImpreciseDateTimeField
instant
- the time instant in millis to update.months
- the months to add (can be negative).DateTimeField.add(long, int)
,
ReadWritableDateTime.addMonths(int)
public long add(long instant, long months)
BaseDateTimeField
add
in class ImpreciseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to add tomonths
- the long value to add, in the units of the fieldBaseDateTimeField.add(long,int)
public int[] add(ReadablePartial partial, int fieldIndex, int[] values, int valueToAdd)
BaseDateTimeField
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
add
in class BaseDateTimeField
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 fieldpublic long addWrapField(long instant, int months)
addWrapField
in class BaseDateTimeField
instant
- the time instant in millis to update.months
- the months to add (can be negative).DateTimeField.addWrapField(long, int)
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant)
ImpreciseDateTimeField
long instant = ... long v = ... long age = getDifferenceAsLong(add(instant, v), instant);The value 'age' is the same as the value 'v'.
The default implementation performs a guess-and-check algorithm using getDurationField().getUnitMillis() and the add() method. Subclasses are encouraged to provide a more efficient implementation.
getDifferenceAsLong
in class ImpreciseDateTimeField
minuendInstant
- the milliseconds from 1970-01-01T00:00:00Z to
subtract fromsubtrahendInstant
- the milliseconds from 1970-01-01T00:00:00Z to
subtract off the minuendpublic long set(long instant, int month)
If the new month has less total days than the specified day of the month, this value is coerced to the nearest sane value. e.g.
07-31 to month 6 = 06-30
03-31 to month 2 = 02-28 or 02-29 depending
set
in class ImpreciseDateTimeField
instant
- the time instant in millis to update.month
- the month (1,12) to update the time to.java.lang.IllegalArgumentException
- if month is invalidpublic DurationField getRangeDurationField()
BaseDateTimeField
getRangeDurationField
in class ImpreciseDateTimeField
public boolean isLeap(long instant)
BaseDateTimeField
For example, a leap year would return true, a non leap year would return false.
This implementation returns false.
isLeap
in class BaseDateTimeField
instant
- the instant to check for leap statuspublic int getLeapAmount(long instant)
BaseDateTimeField
For example, a leap year would return one, a non leap year would return zero.
This implementation returns zero.
getLeapAmount
in class BaseDateTimeField
instant
- the instant to check for leap statuspublic DurationField getLeapDurationField()
BaseDateTimeField
This implementation returns null.
getLeapDurationField
in class BaseDateTimeField
public int getMinimumValue()
BaseDateTimeField
getMinimumValue
in class BaseDateTimeField
public int getMaximumValue()
BaseDateTimeField
getMaximumValue
in class BaseDateTimeField
public long roundFloor(long instant)
BaseDateTimeField
For example, a datetime of 2002-11-02T23:34:56.789, rounded to the lowest whole hour is 2002-11-02T23:00:00.000.
roundFloor
in class ImpreciseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to roundpublic long remainder(long instant)
BaseDateTimeField
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.
remainder
in class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to get the
remainderprivate java.lang.Object readResolve()