final class BasicSingleEraDateTimeField extends BaseDateTimeField
Modifier and Type | Field and Description |
---|---|
private static int |
ERA_VALUE
Value of the era, which will be the same as DateTimeConstants.CE.
|
private java.lang.String |
iEraText
Text value of the era.
|
Constructor and Description |
---|
BasicSingleEraDateTimeField(java.lang.String text)
Restricted constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
get(long instant)
Get the value of this field from the milliseconds.
|
java.lang.String |
getAsText(int fieldValue,
java.util.Locale locale)
Get the human-readable, text value of this field from the field value.
|
DurationField |
getDurationField()
Returns the duration per unit value of this field.
|
int |
getMaximumTextLength(java.util.Locale locale)
Get the maximum text value for this field.
|
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 |
isLenient()
Returns true if the set method is lenient.
|
long |
roundCeiling(long instant)
Round to the highest whole unit of this field.
|
long |
roundFloor(long instant)
Round to the lowest whole unit of this field.
|
long |
roundHalfCeiling(long instant)
Round to the nearest whole unit of this field.
|
long |
roundHalfEven(long instant)
Round to the nearest whole unit of this field.
|
long |
roundHalfFloor(long instant)
Round to the nearest whole unit of this field.
|
long |
set(long instant,
int era)
Sets a value in the milliseconds supplied.
|
long |
set(long instant,
java.lang.String text,
java.util.Locale locale)
Sets a value in the milliseconds supplied from a human-readable, text value.
|
add, add, add, addWrapField, addWrapField, addWrapPartial, convertText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getDifference, getDifferenceAsLong, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getType, isLeap, isSupported, remainder, set, set, set, toString
setExtended
private static final int ERA_VALUE
private final java.lang.String iEraText
BasicSingleEraDateTimeField(java.lang.String text)
public boolean isLenient()
DateTimeField
isLenient
in class DateTimeField
public int get(long instant)
BaseDateTimeField
get
in class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to querypublic long set(long instant, int era)
BaseDateTimeField
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.
set
in class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to set inera
- the value to set, in the units of the fieldpublic long set(long instant, java.lang.String text, java.util.Locale locale)
BaseDateTimeField
This implementation uses convertText(String, Locale)
and
BaseDateTimeField.set(long, int)
.
Note: subclasses that override this method should also override getAsText.
set
in class BaseDateTimeField
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 defaultpublic 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 BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundCeiling(long instant)
BaseDateTimeField
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.
roundCeiling
in class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundHalfFloor(long instant)
BaseDateTimeField
roundHalfFloor
in class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundHalfCeiling(long instant)
BaseDateTimeField
roundHalfCeiling
in class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundHalfEven(long instant)
BaseDateTimeField
If the millisecond value is exactly halfway between the floor and ceiling, the ceiling is chosen over the floor only if it makes this field's value even.
roundHalfEven
in class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to roundpublic DurationField getDurationField()
BaseDateTimeField
getDurationField
in class BaseDateTimeField
public DurationField getRangeDurationField()
BaseDateTimeField
getRangeDurationField
in class BaseDateTimeField
public int getMinimumValue()
BaseDateTimeField
getMinimumValue
in class BaseDateTimeField
public int getMaximumValue()
BaseDateTimeField
getMaximumValue
in class BaseDateTimeField
public java.lang.String getAsText(int fieldValue, java.util.Locale locale)
BaseDateTimeField
The default implementation returns Integer.toString(get(instant)).
Note: subclasses that override this method should also override getMaximumTextLength.
getAsText
in class BaseDateTimeField
fieldValue
- the numeric value to convert to textlocale
- the locale to use for selecting a text symbol, null for defaultpublic int getMaximumTextLength(java.util.Locale locale)
BaseDateTimeField
getMaximumTextLength
in class BaseDateTimeField
locale
- the locale to use for selecting a text symbol