public String getBefore(){
SimpleDateFormat format= new SimpleDateFormat("yyyy-MM-dd");
Date dateNow = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(dateNow);
//calendar .add(Calendar.DAY_OF_YEAR, -1); //一天
//calendar .add(Calendar.WEEK_OF_YEAR, -1); //一周
calendar.add(Calendar.MONTH, -1); // 一个月
Date dateFrom = calendar.getTime();
String beforeTime=format.format(dateFrom);
return beforeTime;
}
网友评论