Here you can find the source of getTomorrowTime()
public static long getTomorrowTime()
//package com.java2s; // the terms of the GNU General Public License as published by the Free Software Foundation; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.concurrent.atomic.AtomicLong; public class Main { private static final AtomicLong TOMORROW = new AtomicLong(-1); /**/*from ww w.j a va 2s. com*/ * Returns the first millisecond of tomorrow. * * @return tomorrow time. */ public static long getTomorrowTime() { final long current = System.currentTimeMillis(); synchronized (TOMORROW) { if (current > TOMORROW.get()) { GregorianCalendar cal = new GregorianCalendar(); cal.add(Calendar.DATE, 1); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); TOMORROW.set(cal.getTimeInMillis()); } } return TOMORROW.get(); } }