Class GJChronology.ImpreciseCutoverField

  • Enclosing class:
    GJChronology

    private final class GJChronology.ImpreciseCutoverField
    extends GJChronology.CutoverField
    Cutover field for variable length fields. These fields internally call set whenever add is called. As a result, the same correction applied to set must be applied to add and addWrapField. Knowing when to use this field requires specific knowledge of how the GJ fields are implemented.
    • Constructor Detail

      • ImpreciseCutoverField

        ImpreciseCutoverField​(DateTimeField julianField,
                              DateTimeField gregorianField,
                              long cutoverMillis)
        Creates a duration field that links back to this.
      • ImpreciseCutoverField

        ImpreciseCutoverField​(DateTimeField julianField,
                              DateTimeField gregorianField,
                              DurationField durationField,
                              long cutoverMillis)
        Uses a shared duration field rather than creating a new one.
        Parameters:
        durationField - shared duration field
      • ImpreciseCutoverField

        ImpreciseCutoverField​(DateTimeField julianField,
                              DateTimeField gregorianField,
                              DurationField durationField,
                              DurationField rangeDurationField,
                              long cutoverMillis)
        Uses shared duration fields rather than creating a new one.
        Parameters:
        durationField - shared duration field
      • ImpreciseCutoverField

        ImpreciseCutoverField​(DateTimeField julianField,
                              DateTimeField gregorianField,
                              DurationField durationField,
                              long cutoverMillis,
                              boolean convertByWeekyear)
        Uses a shared duration field rather than creating a new one.
        Parameters:
        durationField - shared duration field
    • Method Detail

      • add

        public long add​(long instant,
                        int value)
        Description copied from class: BaseDateTimeField
        Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.

        The value will be added to this field. If the value is too large to be added solely to this field, larger fields will increase as required. Smaller fields should be unaffected, except where the result would be an invalid value for a smaller field. In this case the smaller field is adjusted to be in range.

        For example, in the ISO chronology:
        2000-08-20 add six months is 2001-02-20
        2000-08-20 add twenty months is 2002-04-20
        2000-08-20 add minus nine months is 1999-11-20
        2001-01-31 add one month is 2001-02-28
        2001-01-31 add two months is 2001-03-31

        Overrides:
        add in class GJChronology.CutoverField
        Parameters:
        instant - the milliseconds from 1970-01-01T00:00:00Z to add to
        value - the value to add, in the units of the field
        Returns:
        the updated milliseconds
      • add

        public long add​(long instant,
                        long value)
        Description copied from class: BaseDateTimeField
        Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.
        Overrides:
        add in class GJChronology.CutoverField
        Parameters:
        instant - the milliseconds from 1970-01-01T00:00:00Z to add to
        value - the long value to add, in the units of the field
        Returns:
        the updated milliseconds
        See Also:
        BaseDateTimeField.add(long,int)
      • getDifference

        public int getDifference​(long minuendInstant,
                                 long subtrahendInstant)
        Description copied from class: BaseDateTimeField
        Computes the difference between two instants, as measured in the units of this field. Any fractional units are dropped from the result. Calling getDifference reverses the effect of calling add. In the following code:
         long instant = ...
         int v = ...
         int age = getDifference(add(instant, v), instant);
         
        The value 'age' is the same as the value 'v'.
        Overrides:
        getDifference in class GJChronology.CutoverField
        Parameters:
        minuendInstant - the milliseconds from 1970-01-01T00:00:00Z to subtract from
        subtrahendInstant - the milliseconds from 1970-01-01T00:00:00Z to subtract off the minuend
        Returns:
        the difference in the units of this field
      • getDifferenceAsLong

        public long getDifferenceAsLong​(long minuendInstant,
                                        long subtrahendInstant)
        Description copied from class: BaseDateTimeField
        Computes the difference between two instants, as measured in the units of this field. Any fractional units are dropped from the result. Calling getDifference reverses the effect of calling add. In the following code:
         long instant = ...
         long v = ...
         long age = getDifferenceAsLong(add(instant, v), instant);
         
        The value 'age' is the same as the value 'v'.
        Overrides:
        getDifferenceAsLong in class GJChronology.CutoverField
        Parameters:
        minuendInstant - the milliseconds from 1970-01-01T00:00:00Z to subtract from
        subtrahendInstant - the milliseconds from 1970-01-01T00:00:00Z to subtract off the minuend
        Returns:
        the difference in the units of this field
      • getMinimumValue

        public int getMinimumValue​(long instant)
        Description copied from class: BaseDateTimeField
        Get the minimum value for this field evaluated at the specified time.

        This implementation returns the same as BaseDateTimeField.getMinimumValue().

        Overrides:
        getMinimumValue in class GJChronology.CutoverField
        Parameters:
        instant - the milliseconds from 1970-01-01T00:00:00Z to query
        Returns:
        the minimum value for this field, in the units of the field
      • getMaximumValue

        public int getMaximumValue​(long instant)
        Description copied from class: BaseDateTimeField
        Get the maximum value for this field evaluated at the specified time.

        This implementation returns the same as BaseDateTimeField.getMaximumValue().

        Overrides:
        getMaximumValue in class GJChronology.CutoverField
        Parameters:
        instant - the milliseconds from 1970-01-01T00:00:00Z to query
        Returns:
        the maximum value for this field, in the units of the field