获取当前时间的前一个小时

Calendar calen = Calendar.getInstance();//可以对每个时间域单独修改
calen.setTime(new Date());
calen.set(Calendar.HOUR_OF_DAY, calen.get(Calendar.HOUR_OF_DAY) - 1);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time =format.format(calen.getTime());
System.out.println(time);

posted @ 2017-05-04 15:26  学者人生  阅读(3940)  评论(0编辑  收藏  举报