Java Long Number to Time getDelay(long delay, long interval)

Here you can find the source of getDelay(long delay, long interval)

Description

get Delay

License

Apache License

Declaration

public static long getDelay(long delay, long interval) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static long getDelay(long delay, long interval) {
        long current = System.currentTimeMillis();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        try {/*from   w  w  w  .j  a va  2 s . c o m*/
            current = System.currentTimeMillis()
                    - sf.parse(sf.format(new Date())).getTime();
        } catch (ParseException e) {
        }

        if (current >= delay) {
            return current - delay;
        } else {
            long pastTime = delay - current;
            return interval - pastTime % interval;
        }
    }
}

Related

  1. formatTimestampLong(long timestamp, String datepattern, TimeZone tz)
  2. formatToUTC(long datetime)
  3. formatXSDateTime(long lastModified)
  4. getAmPm(long time)
  5. getCollectTimeInLong(Date date)
  6. getDT(long mills)
  7. getDuration(long time)
  8. getElapsedTime(long start, long end)
  9. getElapsedTime(long startTime, long finishTime)