我收到以下错误:
'java.text.ParseException: Unparseable date: "Aug 31 09:53:19 2011"' 格式如下:new SimpleDateFormat("MMM dd HH:mm:ss yyyy");
有人看到问题了吗?
最佳答案
确保您使用的是正确的语言环境。 (SimpleDateFormat(String)
构造函数使用系统默认语言环境,这可能不是您想要使用的语言环境。)
这在我的机器上运行良好:
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));
(例如,当使用 Locale.FRENCH
时,会导致 ParseException
。)
关于java.text.ParseException : Unparseable date 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7254307/