java获取时间并加上2个小时
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long timeNow= System.currentTimeMillis();
long timeLose=System.currentTimeMillis()+2*60*60*1000;
System.out.println(timeNow+" "+timeNow);
String dateNow=sdf.format(new Date(timeNow));
String loseDate=sdf.format(new Date(timeLose));
System.out.println("申请全局access_token时间="+dateNow+" 全局access_token失效时间为="+loseDate);
运行结果:
1449725500714 1449725500714
申请全局access_token时间=2015-12-10 13:31:40 全局access_token失效时间为=2015-12-10 15:31:40