@Test public void times() throws ParseException{ long now = System.currentTimeMillis(); SimpleDateFormat sdfOne = new SimpleDateFormat("yyyy-MM-dd"); long overTime = (now - (sdfOne.parse(sdfOne.format(now)).getTime()))/1000; //当前毫秒数 System.out.println(now); //当前时间 距离当天凌晨 秒数 也就是今天过了多少秒 System.out.println(overTime); //当前时间 距离当天晚上23:59:59 秒数 也就是今天还剩多少秒 long TimeNext = 24*60*60 - overTime; System.out.println(TimeNext); //当天凌晨毫秒数 System.out.println(sdfOne.parse(sdfOne.format(now)).getTime()); //当天凌晨日期 SimpleDateFormat sdfTwo = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.print(sdfTwo.format(sdfOne.parse(sdfOne.format(now)).getTime())); }