Class GJEraDateTimeField


final class GJEraDateTimeField extends BaseDateTimeField
Provides time calculations for the era component of time.
Since:
1.0
  • Field Details

  • Constructor Details

    • GJEraDateTimeField

      GJEraDateTimeField(BasicChronology chronology)
      Restricted constructor
  • Method Details

    • 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)
      Get the Era component of the specified time instant.
      Specified by:
      get in class BaseDateTimeField
      Parameters:
      instant - the time instant in millis to query.
      Returns:
      the value of the field, in the units of the field
    • getAsText

      public String getAsText(int fieldValue, 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
    • set

      public long set(long instant, int era)
      Set the Era component of the specified time instant.
      Specified by:
      set in class BaseDateTimeField
      Parameters:
      instant - the time instant in millis to update.
      era - the era to update the time to.
      Returns:
      the updated time instant.
      Throws:
      IllegalArgumentException - if era is invalid.
    • set

      public long set(long instant, String text, 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
    • getMaximumTextLength

      public int getMaximumTextLength(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
    • readResolve

      private Object readResolve()
      Serialization singleton