Here you can find the source of dateAddHours(Date time, int hours, SimpleDateFormat dateFormat)
public static String dateAddHours(Date time, int hours, SimpleDateFormat dateFormat)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String dateAddHours(Date time, int hours, SimpleDateFormat dateFormat) { long timeLong = time.getTime() / 1000 + 60l * 60 * hours; time.setTime(timeLong * 1000);/* ww w.j av a 2 s. c o m*/ String timeStr = dateFormat.format(time); return timeStr; } }