Why did java.time replace Date and Calendar? How do you use LocalDate, LocalDateTime and Instant?
Short answer
Date, Calendar, SimpleDateFormat can change and are unsafe across threads. java.time (Java 8) can't change, is safe and clear; new code uses only java.time.
3 points to say:
- A date without time uses
LocalDate. - An event moment like
created_atusesInstant. - A
DateTimeFormattercan be a sharedstatic final.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.