The legacy Java API had been a big pain point for Java developers for quite a long time. With the release of Java 8 release (JSR-310), package java.time introduced the new immutable classes that solved the issue with the original classes.
Following articles have been published to help you start with some very common tasks involving the new date-time APIs.
1. Get Current Date and Time
2. Comparing Date and Time
- Comparing Dates Comparison
- Compare LocalDate instances
- Compare LocalDateTime instances
- Compare ZonedDateTime instances
- Differences Between ZonedDateTime and OffsetDateTime
3. Converting Date Time Instances
- Convert between LocalDateTime and ZonedDateTime
- Convert between LocalDate and ZonedDateTime
- Convert between LocalDateTime and LocalDate
- Convert between LocalDate to java.sql.Date
- Convert between LocalTime to java.sql.Time
- Convert java.util.Date to LocalDate
- Convert java.util.Date to LocalDateTime
- Converting Date and Time between Timezones
- Convert a Date to EST/EDT Timezone
- Convert Instant to LocalDateTime, LocalDate or LocalTime
4. Parsing String to Date
- Java Date Format Validation
- Convert String to UTC Date Time
- Convert String to ZonedDateTime
- Convert String to LocalDateTime
- Convert String to LocalDate
- Parsing a String to java.util.Date
- Java Strict, Smart and Lenient Date Resolutions
- Spring boot date format validation annotation (TODO)
- Validate multiple date formats (TODO)
5. Formating Date to String
- Format Dates to String in Java
- Format ZonedDateTime
- Format LocalDateTime
- Format LocalDate
- Format XMLGregorianCalendar
- Location Based Currency Formatting
- Location Based Date Time Formatting
- Display Localized Timestamp in User’s Timezone
- Format date/timestamp in 12 hours pattern
- Format a Milliseconds Duration to Hours, Minutes and Seconds
6. Date and Time Extraction and Manipulation
- Measure Elapsed Time
- Difference Between Two Dates
- Count number of days between two dates
- Get All Dates Between Two Dates
- Check if Date or LocalDate is Weekend
- Calculate business days between two dates
- Add or Subtract Business Days
- Get Next and Previous Date
- Check given year is leap year or not?
- Add or Subtract Days, Months & Years
- Add or Subtract Hours, Minutes and Seconds
- Get Year, Month and Day from Date
- Finding the Day of Week for a Date
- RegEx for matching Date Pattern
- How to Set the JVM Timezone
- Getting the Start and the End of a Day
7. Date Time API
- Java Locale Class
- Java LocalTime class
- Java LocalDate class
- Java LocalDateTime class
- Java ZonedDateTime class
- Java OffsetDateTime (TODO)
- Java XMLGregorianCalendar
- Java SimpleDateFormat (TODO)
- Java DateTimeFormatter
- Java Period
- Java Duration (TODO)
- Java DayOfWeek
- Java TemporalAdjusters
- Java TemporalQuery
- Java InstantSource (TODO)
Happy Learning !!