Java: The First Monday of the Month

The following snippets calculates the next first Monday of the month:

import java.time.DayOfWeek;
import java.time.LocalDate;
import static java.time.temporal.TemporalAdjusters.*;

public class FirstMondayOfTheMonth {

    public static void main(String[] args) {
        var todayInAMonth =;
        var firstMondayOfTheMonth = todayInAMonth.
        System.out.printf("See you at next %s 8pm CET (UTC +1)",firstMondayOfTheMonth);

Because its Java, you don't even have to compile it (Java 11 / JEP-330).

Just run: java and you will get: "See you at next 2020-11-02 8pm CET (UTC +1)"


Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments