Here you can find the source of convertDateToString(Date date, int addHours)
public static String convertDateToString(Date date, int addHours)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String convertDateToString(Date date, int addHours) { Calendar cal = Calendar.getInstance(); // creates calendar cal.setTime(date); // sets calendar time/date cal.add(Calendar.HOUR_OF_DAY, addHours); // adds one hour return convertDateToString(cal.getTime()); // returns new date object }/*from w w w . j a v a2 s .co m*/ public static String convertDateToString(Date date) { DateFormat df = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'"); String reportDate = df.format(date); return reportDate; } }