java 获取指定日期

//可以设置指定那一天:例如,最近一周,参数传入-7,最近一月,参数传入-30...
private
String getBeginDate(int date) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date beginTime = new Date(); Calendar beginCalendar = Calendar.getInstance(); beginCalendar.setTime(beginTime); beginCalendar.add(Calendar.DATE, date); return sdf.format(beginCalendar.getTime()); }

 

posted @ 2015-01-06 13:44  RY一步一个脚印  阅读(231)  评论(0编辑  收藏  举报