获取系统年月日

来源:互联网 发布:coc女皇升级数据2017年 编辑:程序博客网 时间:2024/06/06 08:25
//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//Date d = sdf.parse("2011-10-20");Calendar c = Calendar.getInstance();//c.setTime(d);int year = c.get(Calendar.YEAR);int month = c.get(Calendar.MONTH) + 1;int day = c.get(Calendar.DAY_OF_MONTH);System.out.printf("year=%04d, month=%02d, day=%02d\n", year, month, day);

0 0
原创粉丝点击