Class BasicSingleEraDateTimeField


  • final class BasicSingleEraDateTimeField
    extends BaseDateTimeField
    Provides time calculations for the coptic era component of time.
    Since:
    1.2, refactored from CopticEraDateTimeField
    • 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.
    • Constructor Detail

      • BasicSingleEraDateTimeField

        BasicSingleEraDateTimeField​(java.lang.String text)
        Restricted constructor.
    • 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 class DateTimeField
        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 class BaseDateTimeField
        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 class BaseDateTimeField
        Parameters:
        instant - the milliseconds from 1970-01-01T00:00:00Z to set in
        era - 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) and BaseDateTimeField.set(long, int).

        Note: subclasses that override this method should also override getAsText.

        Overrides:
        set in class BaseDateTimeField
        Parameters:
        instant - the milliseconds from 1970-01-01T00:00:00Z to set in
        text - the text value to set
        locale - 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 class BaseDateTimeField
        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 class BaseDateTimeField
        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 class BaseDateTimeField
        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 class BaseDateTimeField
        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 class BaseDateTimeField
        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 class BaseDateTimeField
        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 class BaseDateTimeField
        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 class BaseDateTimeField
        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 class BaseDateTimeField
        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 class BaseDateTimeField
        Parameters:
        fieldValue - the numeric value to convert to text
        locale - 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 class BaseDateTimeField
        Parameters:
        locale - the locale to use for selecting a text symbol
        Returns:
        the maximum text length