Java.time

java.time is the main API for dates, times, instants, and durations. All the classes in this package are immutable and thread-safe.

LocalDate

This is a class in the package to store a date without a time-zone in the ISO-8601 calendar system. This stores a date like ‘2010-12-03’ and could be used to store a birthday. Example below uses the now() method of the class    to display the current date.

LocalDate dateToday = LocalDate.now();

LocalDateTime

A class in the package for date-time without a time-zone in the ISO-8601 calendar system. Example to get current system localDateTime using the now() method is:

LocalDateTime rightNow = LocalDateTime.now();

There are many more classes and methods in this API that we can not mention here.

For a complete knowlege of Java see the book preview below:

Preview Java Beginner Reference Book

Leave a Reply

Your email address will not be published. Required fields are marked *