上一周的周一和周日
Calendar cl = Calendar.getInstance();
cl.getTime();
cl.add(cl.DAY_OF_YEAR, -cl.get(cl.DAY_OF_WEEK)+1);//get previous Sunday
System.out.println(cl.get(cl.YEAR) + "-" + (cl.get(cl.MONTH)+1) + "-"
+ cl.get(cl.DAY_OF_MONTH) +"week:"+(cl.get(cl.DAY_OF_WEEK)-1));
cl.add(cl.DAY_OF_YEAR, -6 ); //get previous Monday
System.out.println(cl.get(cl.YEAR) + "-" + (cl.get(cl.MONTH)+1) + "-"
+ cl.get(cl.DAY_OF_MONTH) +"week:"+(cl.get(cl.DAY_OF_WEEK)-1));
posted on 2006-03-22 14:08
xnabx 阅读(156)
评论(0) 编辑 收藏