JAVA获取时间的最大值,23:59:59

Posted on 2019-12-04 16:38  jiaoqing。  阅读(6134)  评论(0)    收藏  举报

public static Date getMaxCurrentDate(Date date)throws Exception {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String formatDate = format.format(date);
Calendar cal = Calendar.getInstance();
cal.setTime(format.parse(formatDate));
cal.add(Calendar.DAY_OF_YEAR,1);
return new Date(cal.getTime().getTime()-1);
}

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3