Java Date Now getCurrentTime(long delay, long interval)

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

Description

get Current Time

License

Apache License

Declaration

public static Date getCurrentTime(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 Date getCurrentTime(long delay, long interval) {
        long current = System.currentTimeMillis();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        long date = 0;
        try {//from w w w .  j a  v a2  s. c  om
            date = sf.parse(sf.format(new Date())).getTime();
            current = System.currentTimeMillis() - date - delay;
        } catch (ParseException e) {
        }

        return new Date(date + delay + (current / interval) * interval);
    }
}

Related

  1. getCurrentTime()
  2. getCurrentTime()
  3. getCurrentTime()
  4. getCurrentTime()
  5. getCurrentTime(Date _d)
  6. getCurrentTime(String format)
  7. getCurrentTime(String format)
  8. getCurrentTime(String format)
  9. getCurrentTime(String format)