In this Q&A, we'll go over how to get start and end date of month using Java 8 Time APIs.
Java 8 provides a TemporalAdjusters class to find first, last dates of the month, next month, year etc.
See code snippet below on how to use this:
LocalDate ld1 = LocalDate.parse("2016-02-16");
LocalDate som = ld1.with(TemporalAdjusters.firstDayOfMonth());
ld1 = ld1.with(TemporalAdjusters.lastDayOfMonth());
System.out.println( som.toString());
System.out.println( ld1.toString());
Comments
Post a Comment