Date date=new Date();//取时间
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(calendar.DATE,1);//把日期往后增加一天.整数往后推,负数往前移动
date=calendar.getTime(); //这个时间就是日期往后推一天的结果
//获得当前时间是周几
public static int getDay(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal.get(Calendar.DAY_OF_WEEK);
}
//获得当前时间向前或者向后几天的时间 负数即前几天
public static String getDayBefore(int day){
String beforeDay = "";
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, day);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
beforeDay=formatter.format(c.getTime());
return beforeDay;
}
两个组合使用
请找JODA TIME相关信息!~