Overview
By default
DateTime
class in Joda-Time API is immutable. However Joda-Time gives an option to create Mutable version of
DateTime
called
MutableDateTime
.
This article describes the usage of
MutableDateTime
.
Modify Fields
Use setter methods to modify fields in
MutableDateTime
Add Fields To MutableDateTime
Fields can be added to
MutableDateTime
using the following ways:
- Using add..() methods to directly add the value of field
- Adding Duration: Using the following 3 ways:
- Using DurationFieldType
- Directly adding Duration
- Adding Duration in Millis
- Adding Period
Perform Rounding Operations
Joda-Time API provides supports for rounding off
DateTime
to the nearest field.
In particular, the following types of rounding are supported:
- Floor: Round to the nearest floor
- Ceiling; Round to the nearest ceiling
- Half Floor: Round to the floor if the value of the field is closer to floor or exactly halfway. Else round to ceiling
- Half Ceiling: Round to the floor if the value of the field is closer to floor or exactly halfway. Else round to ceiling
- No Rounding
To start, click on the next arrow. If you find anything missing in the tutorials then please drop in your comments.