Class PreciseDurationDateTimeField

Direct Known Subclasses:
PreciseDateTimeField

public abstract class PreciseDurationDateTimeField extends BaseDateTimeField
Precise datetime field, which has a precise unit duration field.

PreciseDurationDateTimeField is thread-safe and immutable, and its subclasses must be as well.

Since:
1.0
Author:
Brian S O'Neill
  • Constructor Details

  • Method Details

    • isLenient

      public boolean isLenient()
      Returns false by default.
      Specified by:
      isLenient in class DateTimeField
      Returns:
      true if this field is lenient
    • set

      public long set(long instant, int value)
      Set the specified amount of units to the specified time instant.
      Specified by:
      set in class BaseDateTimeField
      Parameters:
      instant - the milliseconds from 1970-01-01T00:00:00Z to set in
      value - value of units to set.
      Returns:
      the updated time instant.
      Throws:
      IllegalArgumentException - if value is too large or too small.
    • roundFloor

      public long roundFloor(long instant)
      This method assumes that this field is properly rounded on 1970-01-01T00:00:00. If the rounding alignment differs, override this method as follows:
       return super.roundFloor(instant + ALIGNMENT_MILLIS) - ALIGNMENT_MILLIS;
       
      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)
      This method assumes that this field is properly rounded on 1970-01-01T00:00:00. If the rounding alignment differs, override this method as follows:
       return super.roundCeiling(instant + ALIGNMENT_MILLIS) - ALIGNMENT_MILLIS;
       
      Overrides:
      roundCeiling in class BaseDateTimeField
      Parameters:
      instant - the milliseconds from 1970-01-01T00:00:00Z to round
      Returns:
      rounded milliseconds
    • remainder

      public long remainder(long instant)
      This method assumes that this field is properly rounded on 1970-01-01T00:00:00. If the rounding alignment differs, override this method as follows:
       return super.remainder(instant + ALIGNMENT_MILLIS);
       
      Overrides:
      remainder in class BaseDateTimeField
      Parameters:
      instant - the milliseconds from 1970-01-01T00:00:00Z to get the remainder
      Returns:
      remainder duration, in milliseconds
    • getDurationField

      public DurationField getDurationField()
      Returns the duration per unit value of this field. For example, if this field represents "minute of hour", then the duration field is minutes.
      Specified by:
      getDurationField in class BaseDateTimeField
      Returns:
      the duration of this field, or UnsupportedDurationField if field has no duration
    • getMinimumValue

      public int getMinimumValue()
      Get the minimum value for the field.
      Specified by:
      getMinimumValue in class BaseDateTimeField
      Returns:
      the minimum value
    • getUnitMillis

      public final long getUnitMillis()
    • getMaximumValueForSet

      protected int getMaximumValueForSet(long instant, int value)
      Called by the set method to get the maximum allowed value. By default, returns getMaximumValue(instant). Override to provide a faster implementation.
      Parameters:
      instant - the instant to query at
      value - the value
      Returns:
      the maximum value