Make sure you're using the correct locale. (The SimpleDateFormat(String)
constructor uses the system default locale, which may not be the one you want to use.)
This works fine on my machine:
String input = "Aug 31 09:53:19 2011";
DateFormat df = new SimpleDateFormat("MMM dd HH:mm:ss yyyy", Locale.US);
System.out.println(df.parseObject(input));
(While using Locale.FRENCH
for instance, results in a ParseException
.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…