Java examples for java.util:Millisecond
get Time Milliseconds
import java.util.Calendar; import java.util.TimeZone; public class Main{ public static void main(String[] argv) throws Exception{ long start = 2; int nNext = 2; int hour = 2; int minute = 2; System.out.println(getTimeMillis(start,nNext,hour,minute)); }/* w ww. j a va 2s .c om*/ public static final long DAY = 24 * HOUR; private static Calendar mCalendar; public static long getTimeMillis(long start, int nNext, int hour, int minute) { initCalendarIfNeeded(); long startTime = start; long targetTime = startTime + nNext * DAY; mCalendar.setTimeInMillis(targetTime); mCalendar.set(Calendar.HOUR_OF_DAY, hour); mCalendar.set(Calendar.MINUTE, minute); return mCalendar.getTimeInMillis(); } private static synchronized void initCalendarIfNeeded() { if (mCalendar == null) { mCalendar = Calendar.getInstance(); TimeZone tz = TimeZone.getTimeZone("GMT+8"); mCalendar.setTimeZone(tz); } } }