Here you can find the source of plusHours(Date date, int hours)
public static Date plusHours(Date date, int hours)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.*; public class Main { private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static Date plusHours(Date date, int hours) { if (date == null) date = getToday();//from ww w. j ava2 s . c om return changeHours(date, hours); } public static Date getToday() { return new Date(); } private static Date changeHours(Date date, int hours) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.HOUR_OF_DAY, hours); return cal.getTime(); } public static String getTime() { return sdfTime.format(new Date()); } }