Here you can find the source of getTimerDate(String time)
public static Date getTimerDate(String time) throws Exception
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static Date getTimerDate(String time) throws Exception { String reg = "\\d{2}:\\d{2}:\\d{2}"; if (time.matches(reg)) { String[] temp = time.split(":"); Calendar c = Calendar.getInstance(); Date now = new Date(); c.setTime(now);/*from w w w . j a v a 2 s . com*/ c.set(Calendar.HOUR, Integer.parseInt(temp[0])); c.set(Calendar.MINUTE, Integer.parseInt(temp[1])); c.set(Calendar.SECOND, Integer.parseInt(temp[2])); Date timer = c.getTime(); if (timer.after(now)) { return timer; } else { c.add(Calendar.DAY_OF_YEAR, 1); return c.getTime(); } } else { return null; } } }