我想更改日期格式。我可以将我的日期格式2014-12-09更改为MMM dd,yyyy(12月09,2014喜欢这个。)但它显示2014年1月9日而不是12月09,2014。如何显示Dec 09,2014?为什么不显示适当的月份?请指导我。我的代码中有什么问题。请建议我。
我的代码
SimpleDateFormat readFormat = null, writeFormat = null;
Date startDate = null, endDate = null;
String strStartDate = "2014-12-09";
readFormat = new SimpleDateFormat("yyyy-mm-dd");
writeFormat = new SimpleDateFormat("MMM dd,yyyy");
try {
startDate = readFormat.parse(strStartDate);
} catch (ParseException e) {
e.printStackTrace();
}
viewHolder.txtStartDate
.setText(writeFormat.format(startDate));
请指导我。 提前谢谢。
答案 0 :(得分:1)
我想你应该试试这个:
readFormat = new SimpleDateFormat("yyyy-MM-dd"); //notice the capital M's