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.
Reference:
Java firstDayOfMonth reference
Share "How to get the first day of the current month in Java?"
Related snippets:
- Get the last Friday of a month in Java
- Get the first Monday of a month in Java
- Get the first day of the week in Java
- Get the first day of the current month in Java
- Get the last day of a month in Java
- Get the number of days between two dates in Java
- Get yesterday's date in Java
- Get tomorrow's date in Java
- Get actual date in Java
Tags:
month first day, get first day of a month, java Technical term:
Get the first day of the current month in Java