Java Week Day getMondayOfThisWeek()

Here you can find the source of getMondayOfThisWeek()

Description

get Monday Of This Week

License

Open Source License

Declaration


public static String getMondayOfThisWeek() 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    /**/*  www.  ja  v  a2s . com*/
     * @Title: getMondayOfThisWeek
     * @Description: TODO
     * @author alterhu2020@gmail.com
     * @param @return
     * @return String return type
     * @throws
     */

    public static String getMondayOfThisWeek() {
        Calendar c = Calendar.getInstance();
        int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
        if (day_of_week == 0)
            day_of_week = 7;
        c.add(Calendar.DATE, -day_of_week + 1);
        return new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
    }
}

Related

  1. getLastWeekMs()
  2. getMon()
  3. getMonday(String date)
  4. getMonday(String date, int weekDay)
  5. getMondayAfter(Date date)
  6. getNextDayOfweek()
  7. getPreDay()
  8. getPreviousDay(long date, int startOfWeek)
  9. getPreviousFriday(String date)