I am pretty new in Joda Time and I have the following doubt:
I have simply created a new empty DateTime
object, in this way:
DateTime dataMovimentoFittizio = new DateTime();
My problem is that is seems to me that then I can't set the year, month and day for this object.
How can I correctly set a specific date into this object?
The Joda-Time classes mostly use immutable objects , designed to not be changed after instantiation.
Use methods to instantiate new objects based partially on the values in the existing object.
The Joda-Time project is now in maintenance mode, and advises migrating to the java.time classes.
The java.time classes strictly use immutable objects .
LocalDate
For a date-only value without time of day and without time zone. Use LocalDate
.
LocalDate ld = LocalDate.of( 2016 , 1 , 23 ); // January 23, 2016
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.