Class BasicWeekyearDateTimeField
- java.lang.Object
-
- org.joda.time.DateTimeField
-
- org.joda.time.field.BaseDateTimeField
-
- org.joda.time.field.ImpreciseDateTimeField
-
- org.joda.time.chrono.BasicWeekyearDateTimeField
-
final class BasicWeekyearDateTimeField extends ImpreciseDateTimeField
Provides time calculations for the week of the weekyear component of time.- Since:
- 1.1, refactored from GJWeekyearDateTimeField
-
-
Field Summary
Fields Modifier and Type Field Description private BasicChronology
iChronology
private static long
serialVersionUID
private static long
WEEK_53
-
Constructor Summary
Constructors Constructor Description BasicWeekyearDateTimeField(BasicChronology chronology)
Restricted constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
add(long instant, int years)
Add the specified years to the specified time instant.long
add(long instant, long value)
Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.long
addWrapField(long instant, int years)
Add to the year component of the specified time instant wrapping around within that component if necessary.int
get(long instant)
Get the Year of a week based year component of the specified time instant.long
getDifferenceAsLong(long minuendInstant, long subtrahendInstant)
Computes the difference between two instants, as measured in the units of this field.int
getLeapAmount(long instant)
Gets the amount by which this field is 'leap' for the specified instant.DurationField
getLeapDurationField()
If this field were to leap, then it would be in units described by the returned duration.int
getMaximumValue()
Get the maximum allowable value for this field.int
getMinimumValue()
Get the minimum allowable value for this field.DurationField
getRangeDurationField()
Returns the range duration of this field.boolean
isLeap(long instant)
Returns whether this field is 'leap' for the specified instant.boolean
isLenient()
Returns true if the set method is lenient.private java.lang.Object
readResolve()
Serialization singletonlong
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 year)
Set the Year of a week based year component of the specified time instant.-
Methods inherited from class org.joda.time.field.ImpreciseDateTimeField
getDifference, getDurationField, getDurationUnitMillis
-
Methods inherited from class org.joda.time.field.BaseDateTimeField
add, addWrapField, addWrapPartial, convertText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getAsText, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getType, isSupported, roundCeiling, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, set, set, toString
-
Methods inherited from class org.joda.time.DateTimeField
setExtended
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
WEEK_53
private static final long WEEK_53
- See Also:
- Constant Field Values
-
iChronology
private final BasicChronology iChronology
-
-
Constructor Detail
-
BasicWeekyearDateTimeField
BasicWeekyearDateTimeField(BasicChronology chronology)
Restricted constructor
-
-
Method Detail
-
isLenient
public boolean isLenient()
Description copied from class:DateTimeField
Returns true if the set method is lenient. If so, it accepts values that are out of bounds. For example, a lenient day of month field accepts 32 for January, converting it to February 1.- Specified by:
isLenient
in classDateTimeField
- Returns:
- true if this field is lenient
-
get
public int get(long instant)
Get the Year of a week based year component of the specified time instant.- Specified by:
get
in classImpreciseDateTimeField
- Parameters:
instant
- the time instant in millis to query.- Returns:
- the year extracted from the input.
- See Also:
DateTimeField.get(long)
-
add
public long add(long instant, int years)
Add the specified years to the specified time instant.- Specified by:
add
in classImpreciseDateTimeField
- Parameters:
instant
- the time instant in millis to update.years
- the years to add (can be negative).- Returns:
- the updated time instant.
- See Also:
DateTimeField.add(long, int)
-
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.- Specified by:
add
in classImpreciseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to add tovalue
- the long value to add, in the units of the field- Returns:
- the updated milliseconds
- See Also:
BaseDateTimeField.add(long,int)
-
addWrapField
public long addWrapField(long instant, int years)
Add to the year component of the specified time instant wrapping around within that component if necessary.- Overrides:
addWrapField
in classBaseDateTimeField
- Parameters:
instant
- the time instant in millis to update.years
- the years to add (can be negative).- Returns:
- the updated time instant.
- See Also:
DateTimeField.addWrapField(long, int)
-
getDifferenceAsLong
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant)
Description copied from class:ImpreciseDateTimeField
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'.The default implementation performs a guess-and-check algorithm using getDurationField().getUnitMillis() and the add() method. Subclasses are encouraged to provide a more efficient implementation.
- Overrides:
getDifferenceAsLong
in classImpreciseDateTimeField
- 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
-
set
public long set(long instant, int year)
Set the Year of a week based year component of the specified time instant.- Specified by:
set
in classImpreciseDateTimeField
- Parameters:
instant
- the time instant in millis to update.year
- the year (-9999,9999) to set the date to.- Returns:
- the updated DateTime.
- Throws:
java.lang.IllegalArgumentException
- if year is invalid.- See Also:
DateTimeField.set(long, int)
-
getRangeDurationField
public DurationField getRangeDurationField()
Description copied from class:BaseDateTimeField
Returns the range duration of this field. For example, if this field represents "hour of day", then the range duration is a day.- Specified by:
getRangeDurationField
in classImpreciseDateTimeField
- Returns:
- the range duration of this field, or null if field has no range
-
isLeap
public boolean isLeap(long instant)
Description copied from class:BaseDateTimeField
Returns whether this field is 'leap' for the specified instant.For example, a leap year would return true, a non leap year would return false.
This implementation returns false.
- Overrides:
isLeap
in classBaseDateTimeField
- Parameters:
instant
- the instant to check for leap status- Returns:
- true if the field is 'leap'
-
getLeapAmount
public int getLeapAmount(long instant)
Description copied from class:BaseDateTimeField
Gets the amount by which this field is 'leap' for the specified instant.For example, a leap year would return one, a non leap year would return zero.
This implementation returns zero.
- Overrides:
getLeapAmount
in classBaseDateTimeField
- Parameters:
instant
- the instant to check for leap status- Returns:
- the amount, in units of the leap duration field, that the field is leap
-
getLeapDurationField
public DurationField getLeapDurationField()
Description copied from class:BaseDateTimeField
If this field were to leap, then it would be in units described by the returned duration. If this field doesn't ever leap, null is returned.This implementation returns null.
- Overrides:
getLeapDurationField
in classBaseDateTimeField
- Returns:
- the leap duration field if field can be leap, null if it can't
-
getMinimumValue
public int getMinimumValue()
Description copied from class:BaseDateTimeField
Get the minimum allowable value for this field.- Specified by:
getMinimumValue
in classBaseDateTimeField
- Returns:
- the minimum valid value for this field, in the units of the field
-
getMaximumValue
public int getMaximumValue()
Description copied from class:BaseDateTimeField
Get the maximum allowable value for this field.- Specified by:
getMaximumValue
in classBaseDateTimeField
- Returns:
- the maximum valid value for this field, in the units of the field
-
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.
- Specified by:
roundFloor
in classImpreciseDateTimeField
- 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 classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to get the remainder- Returns:
- remainder duration, in milliseconds
-
readResolve
private java.lang.Object readResolve()
Serialization singleton
-
-