import java.lang.reflect.Method;
import java.net.URL;
import java.security.GeneralSecurityException;
+import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
* -----------------------------
*/
- // Store JVM default locale for later restoration
- // (we'll have to change the default locale for a while)
- final Locale jvmDefault = Locale.getDefault();
-
// Send locale informations to client
outWriter.print(", \"locales\":[");
for (; pendingLocalesIndex < locales.size(); pendingLocalesIndex++) {
/*
* Date formatting (MM/DD/YYYY etc.)
*/
- // Force our locale as JVM default for a while (SimpleDateFormat
- // uses JVM default)
- Locale.setDefault(l);
- final String df = new SimpleDateFormat().toPattern();
+
+ DateFormat dateFormat = DateFormat.getDateTimeInstance(
+ DateFormat.SHORT, DateFormat.SHORT, l);
+ if (!(dateFormat instanceof SimpleDateFormat)) {
+ System.err
+ .println("Unable to get default date pattern for locale "
+ + l.toString());
+ dateFormat = new SimpleDateFormat();
+ }
+ final String df = ((SimpleDateFormat) dateFormat).toPattern();
+
int timeStart = df.indexOf("H");
if (timeStart < 0) {
timeStart = df.indexOf("h");
}
}
outWriter.print("]"); // Close locales
-
- // Restore JVM default locale
- Locale.setDefault(jvmDefault);
}
/**