首页 > 代码库 > java 获取指定日期

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()); }

 

java 获取指定日期