日期计算

SimpleDateFormat sdf = new SimpleDateFormat("M月dd日");
Calendar calendar = Calendar.getInstance(); //得到日历
calendar.setTime(calendar.getTime());//把当前时间赋给日历
calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天
Date dBefore = calendar.getTime(); //得到前一天的时间

posted @ 2013-06-20 16:50  jshen  阅读(135)  评论(0编辑  收藏  举报