/** * 获取未来 第 past 天的日期 * * @param past * @return */ private static Date getFetureDate(int past) throws ParseException { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + past); Date today = calendar.getTime(); DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String str = format.format(today); Date d2 = format.parse(str); System.out.println(d2); //得到想要测试的时间整天 int dayMis = 1000 * 60 * 60 * 24;//一天的毫秒-1 //返回自 1970 年 1 月 1 日 00:00:00 GMT 以来此 Date 对象表示的毫秒数。 long curMillisecond = d2.getTime();//当天的毫秒 long resultMis = curMillisecond + (dayMis - 1); //当天最后一秒 //得到需要的时间 当天最后一秒 Date resultDate = new Date(resultMis); return resultDate; }
获取第n天后的日期
猜你喜欢
转载自blog.csdn.net/shixiansen6535/article/details/89509501
今日推荐
周排行