2017-06-29 1 views
0

J'ai un problème avec l'analyse de ma date. J'ai la date « Mittwoch, 28. 06. 2017 » comme une chaîne et en utilisant le code suivant pour l'analyser:Date impossible, mais en utilisant les paramètres régionaux corrects - Java

date = new SimpleDateFormat("EEEE, dd. MM. yyyy", Locale.GERMAN).parse("Mittwoch, 28. 06. 2017"); 

Mais me donne toujours l'erreur de date Unparseable. Si je l'exécute sur un autre système, cela fonctionne très bien.

Merci beaucoup

EDIT:

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: J'utilisais une version java ancienne qui a causé l'erreur.

+0

Il faut vous dire pourquoi il ne peut pas unparse que. Publiez cette erreur afin que nous puissions vous aider. EDIT: ** publiez la stacktrace en tant que texte s'il vous plaît ** – AxelH

+0

msg message d'erreur ainsi. – Sanjay

+0

Cause par NullPointerException, c'est un début ... Quelle est la version de Java? – AxelH

Répondre

0

Essayez avec au lieu de EEE EEEE

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

Ne fonctionne toujours pas malheureusement. C'est toujours la même erreur. – SO1992

+0

@ SO1992 Votre code fonctionne sur java 1.8.0_66 – Antoniossss

+0

vérifiez cette URL si cela peut aider: https: //stackoverflow.com/questions/19861642/date-format-parse-exception-eee-mmm-dd-hhmmss-z- yyyy – Sanjay