我想在今天的日期前7天取回日期。 我正在使用SimpleDateFormat获取今天的日期。从android当前获取过去7天的日期
SimpleDateFormat sdf1 = new SimpleDateFormat("dd/MM/yyyy");
请指导我这个
更新的答案,我发现最有用的
SimpleDateFormat sdf=new SimpleDateFormat("dd/MM/yyyy");
String currentDateandTime = sdf.format(new Date());
Date cdate=sdf.parse(currentDateandTime);
Calendar now2= Calendar.getInstance();
now2.add(Calendar.DATE, -7);
String beforedate=now2.get(Calendar.DATE)+"/"+(now2.get(Calendar.MONTH) + 1)+"/"+now2.get(Calendar.YEAR);
Date BeforeDate1=sdf.parse(beforedate);
cdate.compareTo(BeforeDate1);
谢谢你的回复
笑纳答案如果你有你的解决方案;) –