/** * 获取当前时间到凌晨还剩多少秒 * @return */ public static Integer getRemainingTimebyToday(){ long time = 0; try { time = (getNextDay().getTime() - getNowDate().getTime()) / 1000; } catch (Exception e) { logger.error("Exception={}",e.getMessage(),e); } return (int) time; } /** * 获取当前时间 * @return */ public static Date getNowDate(){ return Calendar.getInstance().getTime(); } /** * 获取第二天凌晨的日期 * @return */ public static Date getNextDay() { Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.add(Calendar.DATE, 1); return c.getTime(); }
java获取当前时间到凌晨还剩多少秒
最新推荐文章于 2024-02-22 09:29:16 发布