Handle dates and times correctly with the java.time API
8 steps · about 2 h 15 min · Beginner
- Pick the right date-time class (tutorial, Oracle Java Tutorials, 15 min)
Maps each need to LocalDate, Instant, ZonedDateTime and friends.
- Work with dates (tutorial, Oracle Java Tutorials, 20 min)
LocalDate, DayOfWeek and YearMonth in practice.
- Add times with LocalDateTime (tutorial, Oracle Java Tutorials, 15 min)
Shows date plus time without a zone.
- Record moments with Instant (tutorial, Oracle Java Tutorials, 10 min)
The machine timeline, right for timestamps.
- Convert between time zones (tutorial, Oracle Java Tutorials, 25 min)
Handles ZonedDateTime, offsets and daylight saving.
- Measure with Period and Duration (tutorial, Oracle Java Tutorials, 15 min)
Computes differences between dates and times.
- Parse and format with DateTimeFormatter (tutorial, Oracle Java Tutorials, 20 min)
Turns text into dates and back safely.
- Convert from legacy Date and Calendar (tutorial, Oracle Java Tutorials, 15 min)
Lets you adopt java.time in older code.