Java 怎么获取当前时间前一个小时的时间
2个回答
展开全部
Calendar c = Calendar.getInstance();//可以对每个时间域单独修改
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int date = c.get(Calendar.DATE);
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
//前一个小时的时间
System.out.println(year + "/" + month + "/" + date + " " +(hour - 1)+ ":" +minute + ":" + second);
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int date = c.get(Calendar.DATE);
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
//前一个小时的时间
System.out.println(year + "/" + month + "/" + date + " " +(hour - 1)+ ":" +minute + ":" + second);
2016-11-20
展开全部
java.util.Date now= new java.util.Date();
java.util.Date nowBefore1Hour= new java.util.Date(now.getTime()-3600000);
~
java.util.Date nowBefore1Hour= new java.util.Date(now.getTime()-3600000);
~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询