SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:00:00");//时间格式化
Calendar calendar=Calendar.getInstance();
Date date=new Date();
calendar.setTime(date);
for(int i=0;i<24;i++){//当前时间循环24小时减下去
calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY) - 1);
String time = sdf.format(calendar.getTime());
Timestamp ts = Timestamp.valueOf(time);
System.out.print(ts);
}