How would I get the date of the next first Wednesday of the month using the java calendar class. For example:
Today(24/03/2012) the next first Wednesday will be 04/04/2012
On(05/04/2012) the next first Wednesday will be 02/05/2012
thanks.
LocalDate
& DayOfWeek
In Java 8 and later, we can use the java.time classes including LocalDate
and TemporalAdjusters
, and the DayOfWeek
enum. See Tutorial.
LocalDate firstSundayOfNextMonth =
LocalDate
.now()
.with( TemporalAdjusters.firstDayOfNextMonth() )
.with( TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With