How do you subtract two dates in Java?

Learn how to account for time discontinuities in Java and use the new Java Time API to calculate durations accurately.

By Brian L. Gorman
October 4, 2016
Screenshot from "How do you subtract two dates in Java?" Screenshot from "How do you subtract two dates in Java?"

Time is notoriously difficult to work with in Java. As a result, developers attempting to determine a total duration between events or establish a specific time and date quickly run into timezone and daylight savings time quandaries. In this video, Brian L. Gorman discusses time discontinuities and teaches you how to account for them in your code. Novice Java developers will learn how to work with the LocalDateTime and ZonedDateTime objects in the new Java Time API to calculate durations accurately.

Access in-depth Java training with our Beginning Java Learning Path.

Learn faster. Dig deeper. See farther.

Join the O'Reilly online learning platform. Get a free trial today and find answers on the fly, or master something new and useful.

Learn more

Brian L. Gorman is an experienced .NET developer, certified as an MCSD in C# .NET. Holding a Masters of Science in computer information systems, he has many years of experience instructing college-level SQL database, C#, VB.NET, Java, and Microsoft Office courses. Brian has also authored a number of full technical video courses on these subjects.

Post topics: Software Engineering
Post tags: Questions
Share: