Here you can find the source of getPreHourText(String pattern)
public static String getPreHourText(String pattern)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String getPreHourText(String pattern) { Calendar c = Calendar.getInstance(); return getPreHourText(c.getTime(), pattern); }//ww w . j a v a2 s .c om public static String getPreHourText(Date date, String pattern) { Calendar c = Calendar.getInstance(); c.setTime(date); c.add(Calendar.HOUR_OF_DAY, -1); SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(c.getTime()); } }