Package org.joda.time.field
Class UnsupportedDurationField
- java.lang.Object
-
- org.joda.time.DurationField
-
- org.joda.time.field.UnsupportedDurationField
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<DurationField>
public final class UnsupportedDurationField extends DurationField implements java.io.Serializable
A placeholder implementation to use when a duration field is not supported.UnsupportedDurationField is thread-safe and immutable.
- Since:
- 1.0
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
add(long instant, int value)
Always throws UnsupportedOperationExceptionlong
add(long instant, long value)
Always throws UnsupportedOperationExceptionint
compareTo(DurationField durationField)
Always returns zero, indicating that sort order is not relevant.boolean
equals(java.lang.Object obj)
Compares this duration field to another.int
getDifference(long minuendInstant, long subtrahendInstant)
Always throws UnsupportedOperationExceptionlong
getDifferenceAsLong(long minuendInstant, long subtrahendInstant)
Always throws UnsupportedOperationExceptionstatic UnsupportedDurationField
getInstance(DurationFieldType type)
Gets an instance of UnsupportedDurationField for a specific named field.long
getMillis(int value)
Always throws UnsupportedOperationExceptionlong
getMillis(int value, long instant)
Always throws UnsupportedOperationExceptionlong
getMillis(long value)
Always throws UnsupportedOperationExceptionlong
getMillis(long value, long instant)
Always throws UnsupportedOperationExceptionjava.lang.String
getName()
Get the name of the field.DurationFieldType
getType()
Get the type of the field.long
getUnitMillis()
Always returns zero.int
getValue(long duration)
Always throws UnsupportedOperationExceptionint
getValue(long duration, long instant)
Always throws UnsupportedOperationExceptionlong
getValueAsLong(long duration)
Always throws UnsupportedOperationExceptionlong
getValueAsLong(long duration, long instant)
Always throws UnsupportedOperationExceptionint
hashCode()
Gets a suitable hashcode.boolean
isPrecise()
This field is precise.boolean
isSupported()
This field is not supported.java.lang.String
toString()
Get a suitable debug string.-
Methods inherited from class org.joda.time.DurationField
subtract, subtract
-
-
-
-
Method Detail
-
getInstance
public static UnsupportedDurationField getInstance(DurationFieldType type)
Gets an instance of UnsupportedDurationField for a specific named field. The returned instance is cached.- Parameters:
type
- the type to obtain- Returns:
- the instance
-
getType
public final DurationFieldType getType()
Description copied from class:DurationField
Get the type of the field.- Specified by:
getType
in classDurationField
- Returns:
- field type
-
getName
public java.lang.String getName()
Description copied from class:DurationField
Get the name of the field.By convention, names are plural.
- Specified by:
getName
in classDurationField
- Returns:
- field name
-
isSupported
public boolean isSupported()
This field is not supported.- Specified by:
isSupported
in classDurationField
- Returns:
- false always
-
isPrecise
public boolean isPrecise()
This field is precise.- Specified by:
isPrecise
in classDurationField
- Returns:
- true always
- See Also:
DurationField.getUnitMillis()
-
getValue
public int getValue(long duration)
Always throws UnsupportedOperationException- Specified by:
getValue
in classDurationField
- Parameters:
duration
- the milliseconds to query, which may be negative- Returns:
- the value of the field, in the units of the field, which may be negative
- Throws:
java.lang.UnsupportedOperationException
-
getValueAsLong
public long getValueAsLong(long duration)
Always throws UnsupportedOperationException- Specified by:
getValueAsLong
in classDurationField
- Parameters:
duration
- the milliseconds to query, which may be negative- Returns:
- the value of the field, in the units of the field, which may be negative
- Throws:
java.lang.UnsupportedOperationException
-
getValue
public int getValue(long duration, long instant)
Always throws UnsupportedOperationException- Specified by:
getValue
in classDurationField
- Parameters:
duration
- the milliseconds to query, which may be negativeinstant
- the start instant to calculate relative to- Returns:
- the value of the field, in the units of the field, which may be negative
- Throws:
java.lang.UnsupportedOperationException
-
getValueAsLong
public long getValueAsLong(long duration, long instant)
Always throws UnsupportedOperationException- Specified by:
getValueAsLong
in classDurationField
- Parameters:
duration
- the milliseconds to query, which may be negativeinstant
- the start instant to calculate relative to- Returns:
- the value of the field, in the units of the field, which may be negative
- Throws:
java.lang.UnsupportedOperationException
-
getMillis
public long getMillis(int value)
Always throws UnsupportedOperationException- Specified by:
getMillis
in classDurationField
- Parameters:
value
- the value of the field, which may be negative- Returns:
- the milliseconds that the field represents, which may be negative
- Throws:
java.lang.UnsupportedOperationException
-
getMillis
public long getMillis(long value)
Always throws UnsupportedOperationException- Specified by:
getMillis
in classDurationField
- Parameters:
value
- the value of the field, which may be negative- Returns:
- the milliseconds that the field represents, which may be negative
- Throws:
java.lang.UnsupportedOperationException
-
getMillis
public long getMillis(int value, long instant)
Always throws UnsupportedOperationException- Specified by:
getMillis
in classDurationField
- Parameters:
value
- the value of the field, which may be negativeinstant
- the instant to calculate relative to- Returns:
- the millisecond duration that the field represents, which may be negative
- Throws:
java.lang.UnsupportedOperationException
-
getMillis
public long getMillis(long value, long instant)
Always throws UnsupportedOperationException- Specified by:
getMillis
in classDurationField
- Parameters:
value
- the value of the field, which may be negativeinstant
- the instant to calculate relative to- Returns:
- the millisecond duration that the field represents, which may be negative
- Throws:
java.lang.UnsupportedOperationException
-
add
public long add(long instant, int value)
Always throws UnsupportedOperationException- Specified by:
add
in classDurationField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to add tovalue
- the value to add, in the units of the field- Returns:
- the updated milliseconds
- Throws:
java.lang.UnsupportedOperationException
-
add
public long add(long instant, long value)
Always throws UnsupportedOperationException- Specified by:
add
in classDurationField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to add tovalue
- the value to add, in the units of the field- Returns:
- the updated milliseconds
- Throws:
java.lang.UnsupportedOperationException
-
getDifference
public int getDifference(long minuendInstant, long subtrahendInstant)
Always throws UnsupportedOperationException- Specified by:
getDifference
in classDurationField
- Parameters:
minuendInstant
- the milliseconds from 1970-01-01T00:00:00Z to subtract fromsubtrahendInstant
- the milliseconds from 1970-01-01T00:00:00Z to subtract off the minuend- Returns:
- the difference in the units of this field
- Throws:
java.lang.UnsupportedOperationException
-
getDifferenceAsLong
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant)
Always throws UnsupportedOperationException- Specified by:
getDifferenceAsLong
in classDurationField
- Parameters:
minuendInstant
- the milliseconds from 1970-01-01T00:00:00Z to subtract fromsubtrahendInstant
- the milliseconds from 1970-01-01T00:00:00Z to subtract off the minuend- Returns:
- the difference in the units of this field
- Throws:
java.lang.UnsupportedOperationException
-
getUnitMillis
public long getUnitMillis()
Always returns zero.- Specified by:
getUnitMillis
in classDurationField
- Returns:
- zero always
- See Also:
DurationField.isPrecise()
-
compareTo
public int compareTo(DurationField durationField)
Always returns zero, indicating that sort order is not relevant.- Specified by:
compareTo
in interfacejava.lang.Comparable<DurationField>
- Returns:
- zero always
-
equals
public boolean equals(java.lang.Object obj)
Compares this duration field to another.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to compare to- Returns:
- true if equal
-
hashCode
public int hashCode()
Gets a suitable hashcode.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hashcode
-
toString
public java.lang.String toString()
Get a suitable debug string.- Specified by:
toString
in classDurationField
- Returns:
- debug string
-
-