【发布时间】:2017-06-29 10:38:40
【问题描述】:
我在解析日期时遇到问题。 我将日期“Mittwoch,28. 06. 2017”作为字符串并使用以下代码进行解析:
date = new SimpleDateFormat("EEEE, dd. MM. yyyy", Locale.GERMAN).parse("Mittwoch, 28. 06. 2017");
但这仍然给我无法解析的日期错误。
如果我在另一个系统上运行它,它工作正常。
非常感谢
编辑:
java.text.ParseException: Unparseable date: "Mittwoch, 28. 06. 2017"
at java.text.DateFormat.parse(DateFormat.java:366)
at Download.StartDownload(Download.java:88)
at Download.main(Download.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.NullPointerException
at java.util.Calendar.setTime(Calendar.java:1770)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:943)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:936)
at java.text.DateFormat.format(DateFormat.java:345)
at Download.StartDownload(Download.java:94)
at Download.main(Download.java:42)
... 5 more
编辑:我使用的是导致错误的旧 Java 版本。
【问题讨论】:
-
它应该告诉你为什么它不能解析它。发布该错误,以便我们为您提供帮助。编辑:请以文本形式发布堆栈跟踪
-
我无法重现:它适用于
EEEE和EEEjava 1.8.0_66 -
它也适用于我,但在另一个系统上。如果我将 .jar 文件复制到需要运行该程序的系统,则会出现此错误。
-
谢谢大家。 java版本是错误的。它现在正在工作。没想到会因为版本稍旧而出现这些错误。
-
您可能希望将您的发现作为答案发布,包括有关它不工作的 Java 版本和它工作的版本的信息,供大家学习。我很乐意支持这样的答案。 @SO1992
标签: java date locale unparseable