阅读背景:

java获取当前时间

来源:互联网 
主要有两种方式,其中使用Date比较好控制,代码如下:
//使用Calendar Calendar now = Calendar.getInstance(); System.out.println("年:" + now.get(Calendar.YEAR)); System.out.println("月:" + (now.get(Calendar.MONTH) + 1)); System.out.println("日:" + now.get(Calendar.DAY_OF_MONTH)); System.out.println("时:" + now.get(Calendar.HOUR_OF_DAY)); System.out.println("分:" + now.get(Calendar.MINUTE)); System.out.println("秒:" + now.get(Calendar.SECOND));//使用Calendar Calendar



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: