我在java中有“ valueDate”“ Wed May 08 05:30:00 IST 2013”的日期对象。我正在使用“ yyyy-mm-dd”格式的simpleDateFormat。但是在格式化后,我得到的结果为“ 2013-30” -08”代替“ 2013-05-08”。我做错了。有人可以帮我吗?
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
String formattedValue= dateFormat.format(valueDate);
最佳答案
您必须在月份中使用大写字母“ M”:
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
如您在documentation中看到的
米是分钟
M是一个月