Here you can find the source of getLastSundayBeforeThisWeek()
public static String getLastSundayBeforeThisWeek()
//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()); } }