Java Week Day getLastSundayBeforeThisWeek()

Here you can find the source of getLastSundayBeforeThisWeek()

Description

get Last Sunday Before This Week

License

Open Source License

Declaration

public static String getLastSundayBeforeThisWeek() 

Method Source Code

//package com.java2s;
/************************************************************************************
 * @File name   :      Utils.java//from  www  .j av a  2  s .co  m
 *
 * @Author      :      Brenda Yin
 *
 * @Date        :      2011-1-24
 *
 * @Copyright Notice: 
 * Copyright (c) 2011 . All  Rights Reserved.
 * This software is published under the terms of the  Software 
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * 
 * ----------------------------------------------------------------------------------
 * Date                         Who             Version            Comments
 * 2011-1-24 ????12:43:43        Brenda Yin         1.0                Initial Version
 * 2011-10-19 ????12:43:43        wangzhize         1.0               modify convertStrToSqlKeywordIn() remove;
 * 2011-10-31 ????12:43:43        wangzhize         1.0               modify convertStrToSqlKeywordIn();
 * 2011-11-3 ????01:28:58         Wu Jianxi           1.1             add getDate,getLong,getInt,getString
 ************************************************************************************/

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {

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

Related

  1. getFirstDayOfWeek(String week)
  2. getFirstDayOfWeek(String week)
  3. getFriday(Date date)
  4. getLastDayOfCurrWeek()
  5. getLastDayOfWeek(int year, int month)
  6. getLastWeekday()
  7. getLastWeekDay(int weekDay)
  8. getLastWeekDay(int weekDay)
  9. getLastWeekMs()