Calculate the number of milliseconds from the current time to 12 noon

  private long getSleepTime(){
          Date date=new Date();
          long ndate=date.getTime();
          int nhour=date.getHours();
          Calendar calendar = new GregorianCalendar();
          calendar.setTime(date);
          if(nhour>=12){
            calendar.add(calendar.DATE,1);
          }
          calendar.set(Calendar.HOUR_OF_DAY, 12);
          calendar.set(Calendar.SECOND, 0);
          calendar.set(Calendar.MINUTE, 0);
          calendar.set(Calendar.MILLISECOND, 0);
          long zdate=calendar.getTime().getTime();
            return zdate-ndate;
   }

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326896169&siteId=291194637