Java Hour getDelay(int hour, int min)

Here you can find the source of getDelay(int hour, int min)

Description

get Delay

License

Open Source License

Declaration

public static long getDelay(int hour, int min) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static long getDelay(int hour, int min) {
        if (hour == -1) {
            return 0;
        }/*from  w  ww . j  ava2  s .  c o  m*/
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.setTime(new Date());
        calendar.set(Calendar.HOUR_OF_DAY, hour);
        calendar.set(Calendar.MINUTE, min);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        long delay = calendar.getTime().getTime() - new Date().getTime();
        if (delay <= 0) {
            delay = delay + 24 * 60 * 60 * 1000;
        }
        return delay;
    }
}

Related

  1. getCurrentHour()
  2. getCurrentHour()
  3. getCurrentHour()
  4. getCurrentHours()
  5. getCurrHour()
  6. getDelayToNextHour(int amount, boolean skipNext)
  7. getGMTHour(int localHour)
  8. getHexString(byte[] raw)
  9. getHour()