Here you can find the source of getDateBeforeHours(Date date, int hours)
public static Date getDateBeforeHours(Date date, int hours)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { public static Date getDateBeforeHours(Date date, int hours) { return getDateAfterHours(date, 0 - hours); }/*from www .java2s . co m*/ public static Date getDateAfterHours(Date date, int hours) { Calendar c = Calendar.getInstance(); c.setTime(date); c.add(Calendar.MINUTE, hours * 60); return c.getTime(); } public static long getTime(Date date) { return date.getTime(); } }