Here you can find the source of addCertainTime(java.util.Date date, double hours)
public static java.util.Date addCertainTime(java.util.Date date, double hours)
//package com.java2s; import java.util.Calendar; public class Main { public static java.util.Date addCertainTime(java.util.Date date, double hours) { int s = (int) (hours * 60 * 60); int hour = s / 3600; int min = (s - hour * 3600) / 60; int sec = s - hour * 3600 - min * 60; java.util.Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w w w . j a v a 2s . c o m*/ cal.add(Calendar.HOUR, hour); cal.add(Calendar.MINUTE, min); cal.add(Calendar.SECOND, sec); return cal.getTime(); } }