java获取前天、昨天的时间
解决方法:
Date date=new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, -2);//-2前天 -1昨天
date = calendar.getTime();
String qiantian=sdf.format(date);
java获取前天、昨天的时间
解决方法:
Date date=new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, -2);//-2前天 -1昨天
date = calendar.getTime();
String qiantian=sdf.format(date);
有建议,请留言!