我得到了类似值的字符串String val = "2012-08-01T12:00"
,我使用下面的代码从中创建日历类型,问题是当我打印我得到的月份 07 而不是 08 的数据时,我该如何解决它以获得确切的月份?
1-7-2012-12-0-0
SimpleDateFormat parserSDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
Date date = null;
date = parserSDF.parse(Val);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
System.out.println(cal.get(Calendar.DAY_OF_MONTH) + "-" + cal.get(Calendar.MONTH) + "-"
+ cal.get(Calendar.YEAR) + "-" + cal.get(Calendar.HOUR_OF_DAY) + "-" + cal.get(Calendar.MINUTE)
+ "-" + cal.get(Calendar.SECOND));