Here you can find the source of getLastHour()
public static String getLastHour()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getLastHour() { SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHH"); Calendar cl = Calendar.getInstance(); cl.set(cl.get(cl.YEAR), cl.get(cl.MONTH), cl.get(cl.DAY_OF_MONTH), cl.get(cl.HOUR_OF_DAY) - 1, 0, 0); return sf.format(cl.getTime()); }//from w w w . j a va 2 s . com }