From the course: Java SE 21 Developer (1Z0-830) Cert Prep

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Date-time API foundations, part 2

Date-time API foundations, part 2 - Java Tutorial

From the course: Java SE 21 Developer (1Z0-830) Cert Prep

Date-time API foundations, part 2

- Okay, now there are some important conventions that you'll find in the date-time APIs. You'll need to recognize these and probably be able to answer some questions based on just this knowledge. The first one is immutability. Essentially everything in the date-time API is immutable data types, with the exception of exceptions, no pun intended. Exceptions have to be mutable because you have to be able to add causes to them and things of that sort. So what that means is, just like strings, if you perform an operation on one of these date-time objects, you will make a new object and you'll need to assign the result to a variable or use it in expression for it to do anything useful. We always create these objects using factories or possibly builders of some kind. We don't have accessible constructors for these, so you'll find things like of using values which will create from those values. We have the ability to pass…

Contents