- Instant help with your Java coding problems

Get the first day of the current month in Java

Question:
How to get the first day of the current month in Java?
Answer:
LocalDate now = LocalDate.now();

LocalDate firstDay = now.with(TemporalAdjusters.firstDayOfMonth());
Description:

From Java 8 you can get the first day of the current month using the with() method on the LocalDate object and the firstDayOfMonth() temporal adjuster as a parameter. 

Share "How to get the first day of the current month in Java?"