2017-06-29 7 views
0

日付の解析に問題があります。 は、私は、文字列として日付「2017 Mittwoch、28 06.」と、それを解析するために、次のコードを使用してあります。日付は解析できませんが、正しいロケールを使用しています - Java

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 

EDIT:私はエラーの原因となった古いJavaバージョンを使用していた

非常EDITをいただき、ありがとうございます。

+0

EEEで試してみてください。そのエラーを投稿してください。編集:**スタックトレースをテキストとして投稿してください。** – AxelH

+0

エラーメッセージも投稿してください。 – Sanjay

+0

原因はNullPointerExceptionであるため、これは始まりです... Javaのバージョンは何ですか? – AxelH

答えて

0

は、それはそれをunparseできない理由それはあなたを教えなければならない代わりに、EEEE

date = new SimpleDateFormat("EEE, dd. MM. yyyy", Locale.GERMAN).parse("Mittwoch, 28. 06. 2017") 
+0

まだ残念ながら働いていません。それでも同じエラーです。 – SO1992

+0

@ SO1992あなたのコードはJava 1.8.0_66で動作します – Antoniossss

+0

これが役立つ場合は、このURLをチェックしてください:https://stackoverflow.com/questions/19861642/date-format-parse-exception-eee-mmm-dd-hhmmss-z- yyyy – Sanjay

関連する問題