Reputation: 8383
The following code produces different output in Android and standard jdk
final DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z",
Locale.GERMAN);
final String today = df.format(new Date());
Output:
Android: Mi., 24 Jul 2013 12:33:12 +0200
Standard jdk: Mi, 24 Jul 2013 12:33:12 +0200
In the server side, It is throwing parse exception, any idea?
Upvotes: 2
Views: 1882
Reputation:
Use standard UTC date time format. Not all locales are supported by JDK. So it is safe to use Locale.US specially useful when exchanging data over platform.
Upvotes: 2
Reputation: 136042
I can suggest a workaround:
SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z",
Locale.GERMAN);
DateFormatSymbols dfs = df.getDateFormatSymbols();
String[] swd = {"", "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"};
dfs.setShortWeekdays(swd);
df.setDateFormatSymbols(dfs);
now it will format dates into
Mi, 24 Jul 2013 12:33:12 +0200
in both standard Java and Android
Upvotes: 3