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);
}