Java得到指定日期的时间


//得到指定日期(几天前/几天后)整数往后推,负数往前移动
private Date getAppointDay(int num) throws ParseException {
DateFormat dateFormat = new SimpleDateFormat();
String format = dateFormat.format(new Date());//格式化当前时间
Date resultDate = dateFormat.parse(format);
Calendar calendar = new GregorianCalendar();
calendar.setTime(resultDate);
calendar.add(calendar.DATE,num);//整数往后推,负数往前移动
return calendar.getTime(); //指定的日期
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM