Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.joda.time.field
Class DividedDateTimeField

    java.lang.Object
      org.joda.time.DateTimeField
          org.joda.time.field.BaseDateTimeField
              org.joda.time.field.DecoratedDateTimeField
                  org.joda.time.field.DividedDateTimeField

    public class DividedDateTimeField

extends DecoratedDateTimeField

Divides a DateTimeField such that the retrieved values are reduced by a fixed divisor. The field's unit duration is scaled accordingly, but the range duration is unchanged.

DividedDateTimeField is thread-safe and immutable.

Since:
  1.0
Author:
  Stephen Colebourne, Brian S O'Neill
See Also:
  `RemainderDateTimeField`

Constructor Summary
`DividedDateTimeField(DateTimeField field, DateTimeFieldType type, int divisor)` Constructor.
`DividedDateTimeField(RemainderDateTimeField remainderField, DateTimeFieldType type)` Construct a DividedDateTimeField that compliments the given RemainderDateTimeField.

Method Summary
`long` | `add(long instant, int amount)` Add the specified amount of scaled units to the specified time instant.
`long` | `add(long instant, long amount)` Add the specified amount of scaled units to the specified time instant.
`long` | `addWrapField(long instant, int amount)` Add to the scaled component of the specified time instant, wrapping around within that component if necessary.
`int` | `get(long instant)` Get the amount of scaled units from the specified time instant.
`int` | `getDifference(long minuendInstant, long subtrahendInstant)` Computes the difference between two instants, as measured in the units of this field.
`long` | `getDifferenceAsLong(long minuendInstant, long subtrahendInstant)` Computes the difference between two instants, as measured in the units of this field.
`int` | `getDivisor()` Returns the divisor applied, in the field's units.
`DurationField` | `getDurationField()` Returns a scaled version of the wrapped field's unit duration field.
`int` | `getMaximumValue()` Get the maximum value for the field.
`int` | `getMinimumValue()` Get the minimum value for the field.
`long` | `remainder(long instant)` Returns the fractional duration milliseconds of this field.
`long` | `roundFloor(long instant)` Round to the lowest whole unit of this field.
`long` | `set(long instant, int value)` Set the specified amount of scaled units to the specified time instant.

Methods inherited from class org.joda.time.field.DecoratedDateTimeField
`getRangeDurationField, getWrappedField, isLenient`

Methods inherited from class org.joda.time.field.BaseDateTimeField
`add, addWrapField, addWrapPartial, convertText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getAsText, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getType, isLeap, isSupported, roundCeiling, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, set, set, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### DividedDateTimeField

    public DividedDateTimeField(DateTimeField field,
                                DateTimeFieldType type,
                                int divisor)

  Constructor.

  Parameters:
    `field` - the field to wrap, like "year()".
    `type` - the field type this field will actually use
    `divisor` - divisor, such as 100 years in a century
  Throws:
    `java.lang.IllegalArgumentException` - if divisor is less than two

### DividedDateTimeField

    public DividedDateTimeField(RemainderDateTimeField remainderField,
                                DateTimeFieldType type)

  Construct a DividedDateTimeField that compliments the given RemainderDateTimeField.

  Parameters:
    `remainderField` - complimentary remainder field, like "yearOfCentury()".
    `type` - the field type this field will actually use

Method Detail

### get

    public int get(long instant)

  Get the amount of scaled units from the specified time instant.

  Overrides:
    `get` in class `DecoratedDateTimeField`
  Parameters:
    `instant` - the time instant in millis to query.
  Returns:
    the amount of scaled units extracted from the input.

### add

    public long add(long instant,
                    int amount)

  Add the specified amount of scaled units to the specified time instant. The amount added may be negative.

  Overrides:
    `add` in class `BaseDateTimeField`
  Parameters:
    `instant` - the time instant in millis to update.
    `amount` - the amount of scaled units to add (can be negative).
  Returns:
    the updated time instant.

### add

    public long add(long instant,
                    long amount)

  Add the specified amount of scaled units to the specified time instant. The amount added may be negative.

  Overrides:
    `add` in class `BaseDateTimeField`
  Parameters:
    `instant` - the time instant in millis to update.
    `amount` - the amount of scaled units to add (can be negative).
  Returns:
    the updated time instant.
  See Also:
    `BaseDateTimeField.add(long,int)`

### addWrapField

    public long addWrapField(long instant,
                             int amount)

  Add to the scaled component of the specified time instant, wrapping around within that component if necessary.

  Overrides:
    `addWrapField` in class `BaseDateTimeField`
  Parameters:
    `instant` - the time instant in millis to update.
    `amount` - the amount of scaled units to add (can be negative).
  Returns:
    the updated time instant.

### 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 `BaseDateTimeField`
  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 `BaseDateTimeField`
  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

### set

    public long set(long instant,
                    int value)

  Set the specified amount of scaled units to the specified time instant.

  Overrides:
    `set` in class `DecoratedDateTimeField`
  Parameters:
    `instant` - the time instant in millis to update.
    `value` - value of scaled units to set.
  Returns:
    the updated time instant.
  Throws:
    `java.lang.IllegalArgumentException` - if value is too large or too small.

### getDurationField

    public DurationField getDurationField()

  Returns a scaled version of the wrapped field's unit duration field.

  Overrides:
    `getDurationField` in class `DecoratedDateTimeField`
  Returns:
    the duration of this field, or UnsupportedDurationField if field has no duration

### getMinimumValue

    public int getMinimumValue()

  Get the minimum value for the field.

  Overrides:
    `getMinimumValue` in class `DecoratedDateTimeField`
  Returns:
    the minimum value

### getMaximumValue

    public int getMaximumValue()

  Get the maximum value for the field.

  Overrides:
    `getMaximumValue` in class `DecoratedDateTimeField`
  Returns:
    the maximum value

### 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.

  Overrides:
    `roundFloor` in class `DecoratedDateTimeField`
  Parameters:
    `instant` - the milliseconds from 1970-01-01T00:00:00Z to round
  Returns:
    rounded milliseconds

### remainder

    public long remainder(long instant)

  Description copied from class: `BaseDateTimeField`
  Returns the fractional duration milliseconds of this field. In other words, calling remainder returns the duration that roundFloor would subtract.

  For example, on a datetime of 2002-11-02T23:34:56.789, the remainder by hour is 34 minutes and 56.789 seconds.

  The default implementation computes `instant - roundFloor(instant)`. Subclasses are encouraged to provide a more efficient implementation.

  Overrides:
    `remainder` in class `BaseDateTimeField`
  Parameters:
    `instant` - the milliseconds from 1970-01-01T00:00:00Z to get the remainder
  Returns:
    remainder duration, in milliseconds

### getDivisor

    public int getDivisor()

  Returns the divisor applied, in the field's units.

  Returns:
    the divisor

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD