Here you can find the source of getLastSundayDate()
public static Calendar getLastSundayDate()
//package com.java2s; //License from project: Open Source License import java.sql.Date; import java.util.Calendar; public class Main { /**/*from w w w . j av a2 s . c o m*/ * Gets the last sunday date. * * @return the last sunday date */ public static Calendar getLastSundayDate() { Calendar cal = Calendar.getInstance(); int daydiff = cal.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY; cal.add(Calendar.DATE, daydiff * -1); return cal; } /** * Gets the last sunday date. * * @param d the d * * @return the last sunday date */ public static Calendar getLastSundayDate(Date d) { Calendar cal = Calendar.getInstance(); cal.setTime(d); int daydiff = cal.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY; cal.add(Calendar.DATE, daydiff * -1); return cal; } }