I have the following piece of code:
System.out.println(array[9]);
Date d = df.parse(array[9]);
System.out.println(d.toString());
and the result of this looks like the following:
01.01.2017
Sun Jan 01 00:00:00 CET 2017
My DateFormatter:
DateFormat df = new SimpleDateFormat("dd.MM.yyyy",Locale.GERMANY);
So my question is now why I get the wrong format. First result is a string, which I must convert to date. But I got the wrong format, not the German one (dd.MM.yyyy).
What's wrong?
In your example you should use df.format(d)
if you plan to convert Date
to String
. The default Date.toString()
method will use the predefined format which you can't control.