Here you can find the source of prepareCalendar(int hourOfDay, int minute)
private static Calendar prepareCalendar(int hourOfDay, int minute)
//package com.java2s; import java.util.Calendar; public class Main { private static Calendar prepareCalendar(int hourOfDay, int minute) { Calendar calNow = Calendar.getInstance(); Calendar calSet = (Calendar) calNow.clone(); calSet.set(Calendar.HOUR_OF_DAY, hourOfDay); calSet.set(Calendar.MINUTE, minute); calSet.set(Calendar.SECOND, 0); calSet.set(Calendar.MILLISECOND, 0); if (calSet.compareTo(calNow) <= 0) { // Today Set time passed, count to tomorrow calSet.add(Calendar.DATE, 1); }//w w w .j av a2 s . c o m return calSet; } }