public class OffsetDateTimeField extends DecoratedDateTimeField
OffsetDateTimeField is thread-safe and immutable.
| 构造器和说明 |
|---|
OffsetDateTimeField(DateTimeField field,
DateTimeFieldType type,
int offset)
Constructor.
|
OffsetDateTimeField(DateTimeField field,
DateTimeFieldType type,
int offset,
int minValue,
int maxValue)
Constructor.
|
OffsetDateTimeField(DateTimeField field,
int offset)
Constructor.
|
| 限定符和类型 | 方法和说明 |
|---|---|
long |
add(long instant,
int amount)
Add the specified amount of offset units to the specified time
instant.
|
long |
add(long instant,
long amount)
Add the specified amount of offset units to the specified time
instant.
|
long |
addWrapField(long instant,
int amount)
Add to the offset component of the specified time instant,
wrapping around within that component if necessary.
|
int |
get(long instant)
Get the amount of offset units from the specified time instant.
|
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 value for the field.
|
int |
getMinimumValue()
Get the minimum value for the field.
|
int |
getOffset()
Returns the offset added to the field values.
|
boolean |
isLeap(long instant)
Returns whether this field is 'leap' for the specified instant.
|
long |
remainder(long instant)
Returns the fractional duration milliseconds of this field.
|
long |
roundCeiling(long instant)
Round to the highest whole unit of this field.
|
long |
roundFloor(long instant)
Round to the lowest whole unit of this field.
|
long |
roundHalfCeiling(long instant)
Round to the nearest whole unit of this field.
|
long |
roundHalfEven(long instant)
Round to the nearest whole unit of this field.
|
long |
roundHalfFloor(long instant)
Round to the nearest whole unit of this field.
|
long |
set(long instant,
int value)
Set the specified amount of offset units to the specified time instant.
|
getDurationField, getRangeDurationField, getWrappedField, isLenientadd, addWrapField, addWrapPartial, convertText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getAsText, getDifference, getDifferenceAsLong, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getType, isSupported, set, set, set, set, toStringpublic OffsetDateTimeField(DateTimeField field, int offset)
field - the field to wrap, like "year()".offset - offset to add to field valuesIllegalArgumentException - if offset is zeropublic OffsetDateTimeField(DateTimeField field, DateTimeFieldType type, int offset)
field - the field to wrap, like "year()".type - the field type this field actually usesoffset - offset to add to field valuesIllegalArgumentException - if offset is zeropublic OffsetDateTimeField(DateTimeField field, DateTimeFieldType type, int offset, int minValue, int maxValue)
field - the field to wrap, like "year()".type - the field type this field actually usesoffset - offset to add to field valuesminValue - minimum allowed valuemaxValue - maximum allowed valueIllegalArgumentException - if offset is zeropublic int get(long instant)
get 在类中 DecoratedDateTimeFieldinstant - the time instant in millis to query.public long add(long instant,
int amount)
add 在类中 BaseDateTimeFieldinstant - the time instant in millis to update.amount - the amount of units to add (can be negative).public long add(long instant,
long amount)
add 在类中 BaseDateTimeFieldinstant - the time instant in millis to update.amount - the amount of units to add (can be negative).BaseDateTimeField.add(long, int)public long addWrapField(long instant,
int amount)
addWrapField 在类中 BaseDateTimeFieldinstant - the time instant in millis to update.amount - the amount of units to add (can be negative).public long set(long instant,
int value)
set 在类中 DecoratedDateTimeFieldinstant - the time instant in millis to update.value - value of units to set.IllegalArgumentException - if value is too large or too small.public boolean isLeap(long instant)
BaseDateTimeFieldFor example, a leap year would return true, a non leap year would return false.
This implementation returns false.
isLeap 在类中 BaseDateTimeFieldinstant - the instant to check for leap statuspublic int getLeapAmount(long instant)
BaseDateTimeFieldFor example, a leap year would return one, a non leap year would return zero.
This implementation returns zero.
getLeapAmount 在类中 BaseDateTimeFieldinstant - the instant to check for leap statuspublic DurationField getLeapDurationField()
BaseDateTimeFieldThis implementation returns null.
getLeapDurationField 在类中 BaseDateTimeFieldpublic int getMinimumValue()
getMinimumValue 在类中 DecoratedDateTimeFieldpublic int getMaximumValue()
getMaximumValue 在类中 DecoratedDateTimeFieldpublic long roundFloor(long instant)
BaseDateTimeFieldFor example, a datetime of 2002-11-02T23:34:56.789, rounded to the lowest whole hour is 2002-11-02T23:00:00.000.
roundFloor 在类中 DecoratedDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundCeiling(long instant)
BaseDateTimeFieldFor example, a datetime of 2002-11-02T23:34:56.789, rounded to the highest whole hour is 2002-11-03T00:00:00.000.
The default implementation calls roundFloor, and if the instant is modified as a result, adds one field unit. Subclasses are encouraged to provide a more efficient implementation.
roundCeiling 在类中 BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundHalfFloor(long instant)
BaseDateTimeFieldroundHalfFloor 在类中 BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundHalfCeiling(long instant)
BaseDateTimeFieldroundHalfCeiling 在类中 BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundHalfEven(long instant)
BaseDateTimeFieldIf the millisecond value is exactly halfway between the floor and ceiling, the ceiling is chosen over the floor only if it makes this field's value even.
roundHalfEven 在类中 BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to roundpublic long remainder(long instant)
BaseDateTimeFieldFor 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.
remainder 在类中 BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to get the
remainderpublic int getOffset()
Copyright © 2019. All rights reserved.