android 当前日期的前后n天的用法

来源:互联网 发布:算法里的mod是切莫意思 编辑:程序博客网 时间:2024/06/05 01:56
SimpleDateFormat DateFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
//当前日期的七天前的日期
mCalendar.set(Calendar.DATE, mCalendar.get(Calendar.DATE) - 7);
Date SevenAgoTime=mCalendar.getTime();
String timInfo1=DateFormat.format(SevenAgoTime);
//当前日期的七天后的日期
mCalendar.set(Calendar.DATE, mCalendar.get(Calendar.DATE) + 7);
Date SevenLaterTime=mCalendar.getTime();
String timInfo2=DateFormat.format(SevenLaterTime);
原创粉丝点击