calculate Monday Date - Java java.util

Java examples for java.util:Day

Description

calculate Monday Date

Demo Code


//package com.java2s;
import static java.util.Calendar.DAY_OF_WEEK;
import static java.util.Calendar.MONDAY;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    private static final SimpleDateFormat dataFormat = new SimpleDateFormat(
            "yyyy-MM-dd");

    public static String calculateMondayDate() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(DAY_OF_WEEK, MONDAY);

        return dataFormat.format(calendar.getTime());
    }/*ww w . ja v  a2  s.  co m*/
}

Related Tutorials