我需要将日期格式转换为 NEW_FORMAT日期格式。我想像这样显示2016 年6 月 28日,但无论我通过什么月份 ,它都会显示1月。请检查我失踪的地方..
public class DateClass {
public static void main(String[] args)
{
final String OLD_FORMAT = "yyyy-mm-dd";
final String NEW_FORMAT = "MMMM dd,yyyy";
String oldDateString = "2016-06-28";
String newDateString;
SimpleDateFormat sdf = new SimpleDateFormat(OLD_FORMAT);
Date d;
try {
d = sdf.parse(oldDateString);
sdf.applyPattern(NEW_FORMAT);
newDateString = sdf.format(d);
System.out.println(""+newDateString);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}