Package org.joda.time
Class MutableDateTime.Property
java.lang.Object
org.joda.time.field.AbstractReadableInstantFieldProperty
org.joda.time.MutableDateTime.Property
- All Implemented Interfaces:
Serializable
- Enclosing class:
MutableDateTime
MutableDateTime.Property binds a MutableDateTime to a
DateTimeField allowing powerful datetime functionality to be easily
accessed.
The example below shows how to use the property to change the value of a MutableDateTime object.
MutableDateTime dt = new MutableDateTime(1972, 12, 3, 13, 32, 19, 123); dt.year().add(20); dt.second().roundFloor().minute().set(10);
MutableDateTime.Propery itself is thread-safe and immutable, but the MutableDateTime being operated on is not.
- Since:
- 1.0
- Author:
- Stephen Colebourne, Brian S O'Neill
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionadd
(int value) Adds a value to the millis value.add
(long value) Adds a value to the millis value.addWrapField
(int value) Adds a value, possibly wrapped, to the millis value.protected Chronology
Gets the chronology of the datetime that this property is linked to.getField()
Gets the field being used.protected long
Gets the milliseconds of the datetime that this property is linked to.Gets the mutable datetime being used.Round to the highest whole unit of this field.Round to the lowest whole unit of this field.Round to the nearest whole unit of this field, favoring the ceiling if halfway.Round to the nearest whole unit of this field.Round to the nearest whole unit of this field, favoring the floor if halfway.set
(int value) Sets a value.Sets a text value.Sets a text value.Methods inherited from class org.joda.time.field.AbstractReadableInstantFieldProperty
compareTo, compareTo, equals, get, getAsShortText, getAsShortText, getAsString, getAsText, getAsText, getDifference, getDifferenceAsLong, getDurationField, getFieldType, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValueOverall, getMinimumValue, getMinimumValueOverall, getName, getRangeDurationField, hashCode, isLeap, remainder, toInterval, toString
-
Method Details
-
getField
Gets the field being used.- Specified by:
getField
in classAbstractReadableInstantFieldProperty
- Returns:
- the field
-
getMillis
protected long getMillis()Gets the milliseconds of the datetime that this property is linked to.- Specified by:
getMillis
in classAbstractReadableInstantFieldProperty
- Returns:
- the milliseconds
-
getChronology
Gets the chronology of the datetime that this property is linked to.- Overrides:
getChronology
in classAbstractReadableInstantFieldProperty
- Returns:
- the chronology
- Since:
- 1.4
-
getMutableDateTime
Gets the mutable datetime being used.- Returns:
- the mutable datetime
-
add
Adds a value to the millis value.- Parameters:
value
- the value to add- Returns:
- the mutable datetime being used, so calls can be chained
- See Also:
-
add
Adds a value to the millis value.- Parameters:
value
- the value to add- Returns:
- the mutable datetime being used, so calls can be chained
- See Also:
-
addWrapField
Adds a value, possibly wrapped, to the millis value.- Parameters:
value
- the value to add- Returns:
- the mutable datetime being used, so calls can be chained
- See Also:
-
set
Sets a value.- Parameters:
value
- the value to set.- Returns:
- the mutable datetime being used, so calls can be chained
- See Also:
-
set
Sets a text value.- Parameters:
text
- the text value to setlocale
- optional locale to use for selecting a text symbol- Returns:
- the mutable datetime being used, so calls can be chained
- Throws:
IllegalArgumentException
- if the text value isn't valid- See Also:
-
set
Sets a text value.- Parameters:
text
- the text value to set- Returns:
- the mutable datetime being used, so calls can be chained
- Throws:
IllegalArgumentException
- if the text value isn't valid- See Also:
-
roundFloor
Round to the lowest whole unit of this field.- Returns:
- the mutable datetime being used, so calls can be chained
- See Also:
-
roundCeiling
Round to the highest whole unit of this field.- Returns:
- the mutable datetime being used, so calls can be chained
- See Also:
-
roundHalfFloor
Round to the nearest whole unit of this field, favoring the floor if halfway.- Returns:
- the mutable datetime being used, so calls can be chained
- See Also:
-
roundHalfCeiling
Round to the nearest whole unit of this field, favoring the ceiling if halfway.- Returns:
- the mutable datetime being used, so calls can be chained
- See Also:
-
roundHalfEven
Round to the nearest whole unit of this field. If halfway, the ceiling is favored over the floor only if it makes this field's value even.- Returns:
- the mutable datetime being used, so calls can be chained
- See Also:
-