Skip to Content
Java Coding Problems
book

Java Coding Problems

by Anghel Leonard
September 2019
Intermediate to advanced
816 pages
18h 47m
English
Packt Publishing
Content preview from Java Coding Problems

Starting with JDK 8

Starting with JDK 8, the recommended way to represent date-time information is via Temporal (for example, DateTime, DateLocalTime, ZonedDateTime, and so on).

Let's assume the following two LocalDate objects, January 1, 2018, and March 1, 2019:

LocalDate ld1 = LocalDate.of(2018, 1, 1);LocalDate ld2 = LocalDate.of(2019, 3, 1);

The simplest way to compute the difference between these two Temporal objects is via the ChronoUnit class. Beside representing the standard set of date periods units, ChronoUnit comes with several handy methods, including between(Temporal t1Inclusive, Temporal t2Exclusive). As its name suggests, the between() method calculates the amount of time between two Temporal objects. Let's see it at work to ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Coding Problems - Second Edition

Java Coding Problems - Second Edition

Anghel Leonard
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan
The Well-Grounded Java Developer, Second Edition

The Well-Grounded Java Developer, Second Edition

Benjamin Evans, Martijn Verburg, Jason Clark

Publisher Resources

ISBN: 9781789801415Supplemental Content