LocalDateTime
Dates and times are everywhere in real-world apps:
User sign-up dates
Order timestamps
Booking systems
Log files, audit trails, reports
Before Java 8, the old Date and Calendar APIs were confusing and error-prone.
Java 8 introduced java.time โ a modern, safe, and clear date-time framework.
โ
Key idea:
LocalDateTime is an immutable class that combines date + time but no timezone.
For example: 2025-07-03T15:30:00.
Use LocalDateTime when you need:
A precise timestamp
No need for timezone math
A safe, predictable date-time representation
You can create a LocalDateTime in multiple ways:
The current moment
A specific date-time
From strings or other time objects
Mini Lab: Basic LocalDateTime
Key points:
now() returns the current system date-time.
of() builds a specific one.
plusDays(), minusHours() create new modified copies โ original stays unchanged.