public abstract class DurationField extends java.lang.Object implements java.lang.Comparable<DurationField>
This design is extensible so, if you wish, you can extract a different field from the millisecond duration. A number of standard implementations are provided to assist.
Constructor and Description 

DurationField() 
Modifier and Type  Method and Description 

abstract long 
add(long instant,
int value)
Adds a duration value (which may be negative) to the instant.

abstract long 
add(long instant,
long value)
Adds a duration value (which may be negative) to the instant.

abstract int 
getDifference(long minuendInstant,
long subtrahendInstant)
Computes the difference between two instants, as measured in the units
of this field.

abstract long 
getDifferenceAsLong(long minuendInstant,
long subtrahendInstant)
Computes the difference between two instants, as measured in the units
of this field.

abstract long 
getMillis(int value)
Get the millisecond duration of this field from its value, which is
approximate if this field is imprecise.

abstract long 
getMillis(int value,
long instant)
Get the millisecond duration of this field from its value relative to an
instant.

abstract long 
getMillis(long value)
Get the millisecond duration of this field from its value, which is
approximate if this field is imprecise.

abstract long 
getMillis(long value,
long instant)
Get the millisecond duration of this field from its value relative to an
instant.

abstract java.lang.String 
getName()
Get the name of the field.

abstract DurationFieldType 
getType()
Get the type of the field.

abstract long 
getUnitMillis()
Returns the amount of milliseconds per unit value of this field.

abstract int 
getValue(long duration)
Get the value of this field from the milliseconds, which is approximate
if this field is imprecise.

abstract int 
getValue(long duration,
long instant)
Get the value of this field from the milliseconds relative to an
instant.

abstract long 
getValueAsLong(long duration)
Get the value of this field from the milliseconds, which is approximate
if this field is imprecise.

abstract long 
getValueAsLong(long duration,
long instant)
Get the value of this field from the milliseconds relative to an
instant.

abstract boolean 
isPrecise()
Is this field precise.

abstract boolean 
isSupported()
Returns true if this field is supported.

long 
subtract(long instant,
int value)
Subtracts a duration value (which may be negative) from the instant.

long 
subtract(long instant,
long value)
Subtracts a duration value (which may be negative) from the instant.

abstract java.lang.String 
toString()
Get a suitable debug string.

public abstract DurationFieldType getType()
public abstract java.lang.String getName()
By convention, names are plural.
public abstract boolean isSupported()
public abstract boolean isPrecise()
getUnitMillis()
public abstract long getUnitMillis()
For imprecise fields, the unit size is variable, and so this method returns a suitable average value.
isPrecise()
public abstract int getValue(long duration)
duration
 the milliseconds to query, which may be negativejava.lang.ArithmeticException
 if the value is too large for an intpublic abstract long getValueAsLong(long duration)
duration
 the milliseconds to query, which may be negativepublic abstract int getValue(long duration, long instant)
If the millisecond duration is positive, then the instant is treated as a "start instant". If negative, the instant is treated as an "end instant".
duration
 the milliseconds to query, which may be negativeinstant
 the start instant to calculate relative tojava.lang.ArithmeticException
 if the value is too large for an intpublic abstract long getValueAsLong(long duration, long instant)
If the millisecond duration is positive, then the instant is treated as a "start instant". If negative, the instant is treated as an "end instant".
duration
 the milliseconds to query, which may be negativeinstant
 the start instant to calculate relative topublic abstract long getMillis(int value)
value
 the value of the field, which may be negativepublic abstract long getMillis(long value)
value
 the value of the field, which may be negativepublic abstract long getMillis(int value, long instant)
If the value is positive, then the instant is treated as a "start instant". If negative, the instant is treated as an "end instant".
value
 the value of the field, which may be negativeinstant
 the instant to calculate relative topublic abstract long getMillis(long value, long instant)
If the value is positive, then the instant is treated as a "start instant". If negative, the instant is treated as an "end instant".
value
 the value of the field, which may be negativeinstant
 the instant to calculate relative topublic abstract long add(long instant, int value)
instant
 the milliseconds from 19700101T00:00:00Z to add tovalue
 the value to add, in the units of the fieldpublic abstract long add(long instant, long value)
instant
 the milliseconds from 19700101T00:00:00Z to add tovalue
 the value to add, in the units of the fieldpublic long subtract(long instant, int value)
instant
 the milliseconds from 19700101T00:00:00Z to subtract fromvalue
 the value to subtract, in the units of the fieldpublic long subtract(long instant, long value)
instant
 the milliseconds from 19700101T00:00:00Z to subtract fromvalue
 the value to subtract, in the units of the fieldpublic abstract int getDifference(long minuendInstant, long subtrahendInstant)
long instant = ... int v = ... int age = getDifference(add(instant, v), instant);The value 'age' is the same as the value 'v'.
minuendInstant
 the milliseconds from 19700101T00:00:00Z to
subtract fromsubtrahendInstant
 the milliseconds from 19700101T00:00:00Z to
subtract off the minuendpublic abstract long getDifferenceAsLong(long minuendInstant, long subtrahendInstant)
long instant = ... long v = ... long age = getDifferenceAsLong(add(instant, v), instant);The value 'age' is the same as the value 'v'.
minuendInstant
 the milliseconds from 19700101T00:00:00Z to
subtract fromsubtrahendInstant
 the milliseconds from 19700101T00:00:00Z to
subtract off the minuendpublic abstract java.lang.String toString()
toString
in class java.lang.Object
"Copyright © 2010  2018 Adobe Systems Incorporated. All Rights Reserved"