Java ClassesLesson 43Free preview
Java Date
This lesson is part of Java · All levels
Summary
This lesson discusses how to display and manipulate dates and times in Java. The old method used class java.util.Date, while the modern method suggested was the java.time package such as LocalDate and LocalDateTime. The class is immutable and more accurate for the needs of date calculation.
Key points
- New Date().toString() displays the current date and time easily
- Since Java 8, use java.time.LocalDate, LocalTime, and LocalDateTime
- LocalDate only keeps dates without clockwork
- Methods such as getYear(), getMonthValue(), and getDayOfMonth() take the date part
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.