标签:java
1、如何获得上周星期日的日期
public class DateTest { public static void main(String[] args) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); System.out.println(sdf.format(getLastWeekSunday())); } /** * 获得上周星期日的日期 * @return */ public static Date getLastWeekSunday(){ Calendar date = Calendar.getInstance(); //将每周第一天设为星期一,默认是星期天 date.setFirstDayOfWeek(Calendar.MONDAY); //周数减一,即上周 date.add(Calendar.WEEK_OF_MONTH, -1); //设为星期天 date.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); return date.getTime(); }
标签:java
原文地址:http://blog.csdn.net/panxueji/article/details/39277049