获取系统年月日

//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);

posted on 2016-07-05 14:52  菜鸟Z  阅读(120)  评论(0编辑  收藏  举报

导航