Class PreciseDateTimeField

    • Field Detail

      • iRange

        private final int iRange
        The maximum range in the correct units
    • Constructor Detail

      • PreciseDateTimeField

        public PreciseDateTimeField​(DateTimeFieldType type,
                                    DurationField unit,
                                    DurationField range)
        Constructor.
        Parameters:
        type - the field type this field uses
        unit - precise unit duration, like "seconds()".
        range - precise range duration, preferably a multiple of the unit, like "minutes()".
        Throws:
        java.lang.IllegalArgumentException - if either duration field is imprecise
        java.lang.IllegalArgumentException - if unit milliseconds is less than one or effective value range is less than two.
    • Method Detail

      • get

        public int get​(long instant)
        Get the amount of fractional units from the specified time instant.
        Specified by:
        get in class BaseDateTimeField
        Parameters:
        instant - the milliseconds from 1970-01-01T00:00:00Z to query
        Returns:
        the amount of fractional units extracted from the input.
      • addWrapField

        public long addWrapField​(long instant,
                                 int amount)
        Add to the component of the specified time instant, wrapping around within that component if necessary.
        Overrides:
        addWrapField in class BaseDateTimeField
        Parameters:
        instant - the milliseconds from 1970-01-01T00:00:00Z to add to
        amount - the amount of units to add (can be negative).
        Returns:
        the updated time instant.
      • set

        public long set​(long instant,
                        int value)
        Set the specified amount of units to the specified time instant.
        Overrides:
        set in class PreciseDurationDateTimeField
        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:
        java.lang.IllegalArgumentException - if value is too large or too small.
      • getRangeDurationField

        public DurationField getRangeDurationField()
        Returns the range duration of this field. For example, if this field represents "minute of hour", then the range duration field is an hours.
        Specified by:
        getRangeDurationField in class BaseDateTimeField
        Returns:
        the range duration of this field, or null if field has no range
      • getMaximumValue

        public int getMaximumValue()
        Get the maximum value for the field.
        Specified by:
        getMaximumValue in class BaseDateTimeField
        Returns:
        the maximum value
      • getRange

        public int getRange()
        Returns the range of the field in the field's units.

        For example, 60 for seconds per minute. The field is allowed values from 0 to range - 1.

        Returns:
        unit range