java设置按钮不可见(java Android get date before 7 days (one week) Stack Overflow)
导读:Parse the date: Date...
Parse the date:
Date myDate = dateFormat.parse(dateString);And then either figure out how many milliseconds you need to subtract:
Date newDate =newDate(myDate.getTime()-604800000L);// 7 * 24 * 60 * 60 * 1000Or use the API provided by the java.util.Calendar class:
Calendar calendar =Calendar.getInstance(); calendar.setTime(myDate); calendar.add(Calendar.DAY_OF_YEAR,-7);Date newDate = calendar.getTime();Then, if you need to, convert it back to a String:
String date = dateFormat.format(newDate);创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!