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.

Time-zone considerations, part 3

Time-zone considerations, part 3 - Java Tutorial

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

Time-zone considerations, part 3

- The Instant API, of course, also provides some useful features. One of the things we need to understand about Instant is that they only deal in nanoseconds, microseconds, milliseconds or seconds. No larger temporal unit is available to us. We can make these things from seconds and so forth. We can ask about now, we can ask from epoch milliseconds or epoch seconds and we can also pass things. We can adjust into other data types. But as mentioned, know that there are only a few fields supported. Nothing larger than seconds. We have accesses for get, getLong values, and getXxx. But again, we're dealing with things where we can only get seconds and smaller things. We can mutate and we can truncate into. We can ask what is the difference from a given instant until another instant and we can ask if two instance are equal. Let's take a look at some more code. We'll start with two periods defined. One is one year, which we'll…

Contents