From the course: Java 8 Essential Training

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Working with dates and times

Working with dates and times - Java Tutorial

From the course: Java 8 Essential Training

Working with dates and times

- There are two completely different APIs for working with dates and times in Java: the original set of classes that were introduced with Java in the mid-90s, and a completely new date-time API that was brought in with Java 8. If you're working on, say, a Java Enterprise Edition application and you're working with a Java 8 runtime, then you can use the new API. But if you're working in older versions of Java or if you're working in Android, which doesn't yet implement Java 8 features, then you'll need to use the older classes. I'm working in the project DatesAndTimes, which has a main class with an empty main method. And I'll start with the original date API. I'll create an instance of the Date class, which is a member of the java.util package. Because it's not a member of java.lang, it must be imported in order to use it. I'll name my object d and then I'll instantiate with new and then the constructor method, date. There…

Contents