Programming with dates and times is essential to most applications. This course will teach you how to use the java.time library, introduced in Java 8, for handling dates, times, time periods, time zones, and daylight saving time transitions.
Handling dates and times is an essential part of most business and scientific applications. In this course, Programming with Dates and Times in Java 8, you will learn all about the much-needed new library in Java 8: the java.time API. First, you will learn the basic use of the core java.time classes. Next, you will discover how the library handles the complexities of time zones and daylight saving time transitions. Finally, you will explore the interconversion of java.time classes with other Java types and with database representations. When you are finished with this course, you will have a thorough knowledge of how to use this modern Java library for the fundamentally important problems of handling dates and times in your applications.
Maurice Naftalin is a Java Champion, author or co-author of two books on Java, and a three-times JavaOne Rockstar. He works as a developer and consultant, and over the last twenty years has trained thousands of students in intermediate and advanced Java topics.
Section Introduction Transcripts
Section Introduction Transcripts
Course Overview Hi everyone. My name is Maurice Naftalin. Welcome to my course, Programming with Dates and Times in Java 8. I'm a freelance trainer and developer working with Java from its start. For most of that time, it's been tough to write Java programs using dates and times because there were many problems with the original library. Java 8 finally put that right with the high quality java. time API, which we'll study in detail in this course. Some of the topics that we'll cover include the major classes of the library representing dates and times, time zones, durations, and time periods, handling time zone and daylight saving time changes, parsing and formatting date/time values, and testing programs that use dates and times. By the end of this course, you'll understand the ideas that underly the design of the library and you'll be ready to use it for calculating durations, persisting date/time values in relational databases, communicating time-critical data across time zones, and many other applications. Before beginning the course, you should be familiar with the everyday use of Java, pre-Java 8, although the course uses some Java 8 syntax. That's explained as we go along. I hope you'll join me on this journey to learn date and time programming with this course, Programming with Dates and Times in Java 8 at Pluralsight.
Working with Time Zones Hello, and welcome back to this course on Programming with Dates and times in Java 8. In this module, we'll further explore the java. time API, focusing mainly on the types that help us to handle time zones and daylight savings time changes. Time zones are represented by the classes ZoneOffset and ZoneId. And DateTimeClasses that contain time zone information are respectively OffsetDateTime and ZonedDateTime. At the end of the module, we'll look at the important idea of a temporal adjuster, which encapsulates the strategy behind the adjustment methods that we met in the last module. In the demo, we'll see how to use what we've learned to code one of the central operations of the todo scheduler, that of combining work periods and fixed events. Let's get a quick overview of the four main time zone classes before we go onto to look at them in detail. ZoneOffset and ZoneId provide different ways of identifying a time zone, in the case of ZoneOffset by specifying a fixed amount, say, three hours before standard or universal time. ZoneId could be a ZoneOffset-- ZoneOffset is a subclass of ZoneId-- or, it could be a geographical identifier, like America New York, which contains not only a fixed offset, but also rules for daylight saving time transitions. OffsetDateTime and ZonedDateTime combine a LocalDateTime with time zone information represented by one of these two time zone classes.