Capital letter in SimpleDateFormat
executing this piece of code:
SimpleDateFormat sdfIn = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = sdfIn.parse(value11);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SimpleDateFormat sdfOut = new SimpleDateFormat("MMM d, yyyy");
System.out.println(sdfOut.format( date ));
I an getting this output nov 23, 2005
instead of Nov 23, 2005
开发者_StackOverflow which would be much better.
The exact strings that get generated depend on the locale you're in. If you just use
new SimpleDateFormat("MMM d, yyyy");
then the system default locale will be used. Your default locale probably renders the month as nov
rather than Nov
.
if you want a specific locale to be used, pass it in to the constructor, e.g.
new SimpleDateFormat("MMM d, yyyy", Locale.US);
精彩评论