Class BasicSingleEraDateTimeField
- java.lang.Object
-
- org.joda.time.DateTimeField
-
- org.joda.time.field.BaseDateTimeField
-
- org.joda.time.chrono.BasicSingleEraDateTimeField
-
final class BasicSingleEraDateTimeField extends BaseDateTimeField
Provides time calculations for the coptic era component of time.- Since:
- 1.2, refactored from CopticEraDateTimeField
-
-
Constructor Summary
Constructors Constructor Description BasicSingleEraDateTimeField(java.lang.String text)
Restricted constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class org.joda.time.field.BaseDateTimeField
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
-
Methods inherited from class org.joda.time.DateTimeField
setExtended
-
-
-
-
Field Detail
-
ERA_VALUE
private static final int ERA_VALUE
Value of the era, which will be the same as DateTimeConstants.CE.- See Also:
- Constant Field Values
-
iEraText
private final java.lang.String iEraText
Text value of the era.
-
-
Method Detail
-
isLenient
public boolean isLenient()
Description copied from class:DateTimeField
Returns 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:
isLenient
in classDateTimeField
- Returns:
- true if this field is lenient
-
get
public int get(long instant)
Description copied from class:BaseDateTimeField
Get the value of this field from the milliseconds.- Specified by:
get
in 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
-
set
public long set(long instant, int era)
Description copied from class:BaseDateTimeField
Sets 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:
set
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to set inera
- 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:BaseDateTimeField
Sets 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:
set
in 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
-
roundFloor
public long roundFloor(long instant)
Description copied from class:BaseDateTimeField
Round 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:
roundFloor
in 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:BaseDateTimeField
Round 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:
roundCeiling
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
roundHalfFloor
public long roundHalfFloor(long instant)
Description copied from class:BaseDateTimeField
Round to the nearest whole unit of this field. If the given millisecond value is closer to the floor or is exactly halfway, this function behaves like roundFloor. If the millisecond value is closer to the ceiling, this function behaves like roundCeiling.- Overrides:
roundHalfFloor
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
roundHalfCeiling
public long roundHalfCeiling(long instant)
Description copied from class:BaseDateTimeField
Round to the nearest whole unit of this field. If the given millisecond value is closer to the floor, this function behaves like roundFloor. If the millisecond value is closer to the ceiling or is exactly halfway, this function behaves like roundCeiling.- Overrides:
roundHalfCeiling
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
roundHalfEven
public long roundHalfEven(long instant)
Description copied from class:BaseDateTimeField
Round to the nearest whole unit of this field. If the given millisecond value is closer to the floor, this function behaves like roundFloor. If the millisecond value is closer to the ceiling, this function behaves like roundCeiling.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.
- Overrides:
roundHalfEven
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
getDurationField
public DurationField getDurationField()
Description copied from class:BaseDateTimeField
Returns 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:
getDurationField
in classBaseDateTimeField
- Returns:
- the duration of this field, or UnsupportedDurationField if field has no duration
-
getRangeDurationField
public DurationField getRangeDurationField()
Description copied from class:BaseDateTimeField
Returns the range duration of this field. For example, if this field represents "hour of day", then the range duration is a day.- Specified by:
getRangeDurationField
in classBaseDateTimeField
- Returns:
- the range duration of this field, or null if field has no range
-
getMinimumValue
public int getMinimumValue()
Description copied from class:BaseDateTimeField
Get the minimum allowable value for this field.- Specified by:
getMinimumValue
in classBaseDateTimeField
- Returns:
- the minimum valid value for this field, in the units of the field
-
getMaximumValue
public int getMaximumValue()
Description copied from class:BaseDateTimeField
Get the maximum allowable value for this field.- Specified by:
getMaximumValue
in classBaseDateTimeField
- Returns:
- the maximum valid value for this field, in the units of the field
-
getAsText
public java.lang.String getAsText(int fieldValue, java.util.Locale locale)
Description copied from class:BaseDateTimeField
Get 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:
getAsText
in 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
-
getMaximumTextLength
public int getMaximumTextLength(java.util.Locale locale)
Description copied from class:BaseDateTimeField
Get the maximum text value for this field. The default implementation returns the equivalent of Integer.toString(getMaximumValue()).length().- Overrides:
getMaximumTextLength
in classBaseDateTimeField
- Parameters:
locale
- the locale to use for selecting a text symbol- Returns:
- the maximum text length
-
-