Here you can find the source of getCurrentTime(long delay, long interval)
public static Date getCurrentTime(long delay, long interval)
//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); } }