Here you can find the source of getDateInterval4EndDate(Date date, int hourModify)
public static Date getDateInterval4EndDate(Date date, int hourModify)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static Date getDateInterval4EndDate(Date date, int hourModify) { Calendar c = Calendar.getInstance(); c.setTime(date);//from www . jav a2s . c o m int second = c.get(Calendar.SECOND); int hour = c.get(Calendar.HOUR); c.set(Calendar.SECOND, second + 3); c.set(Calendar.HOUR, hour - hourModify); return c.getTime(); } }