Pick the type that matches the concept
LocalDate— calendar date, no zone (birthday, invoice date).LocalDateTime— wall clock without zone — ambiguous for stored events.Instant— absolute UTC moment — store this in databases.ZonedDateTime— local rules + zone (meetings that survive DST).Duration— time-based amount;Period— calendar-based amount.
public class Example {
public static void main(String[] args) {
LocalDate launch = LocalDate.of(2026, Month.MARCH, 15);
Instant recorded = Instant.now();
ZonedDateTime tokyo = launch.atTime(9, 30).atZone(ZoneId.of("Asia/Tokyo"));
Period age = Period.between(birthDate, LocalDate.now());
Duration meeting = Duration.ofMinutes(90);
}
}
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 2 sections
- Immutable updates
- Formatting
Test yourself
Answer these before moving on — recall is what makes it stick.