Unparseable date, but using the correct locale - Java

520 Views Asked by At

I'm having a problem with parsing my date. I have the date "Mittwoch, 28. 06. 2017" as a string and using the following code for parsing it:

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

But this is still giving me the unparseable date error.

If I run it on another system, it's working fine.

Thank you very much

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: I was using a older java version that caused the error.

1

There are 1 best solutions below

3
On

Try with EEE instead of EEEE

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