/** * 获得指定日期的前一天的23:59:59 * * @param specifiedDay 指定日期 * @return 前一天日期 23:59:59 */ public static Date getSpecifiedDayBefore(Date specifiedDay) { if (null == specifiedDay) { return null; } Date newDate = null; try { Calendar c = Calendar.getInstance(); c.setTime(specifiedDay); int day = c.get(Calendar.DATE); c.set(Calendar.DATE, day - 1); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String newDateStr = simpleDateFormat.format(c.getTime()) " 23:59:59"; SimpleDateFormat newSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); newDate = newSimpleDateFormat.parse(newDateStr); } catch (ParseException e) { log.info("日期转换错误" e.getMessage()); } return newDate; }
获取指定日期的前一天23:59:59
2022-12-15 15:15:07
浏览数 (1)