]> source.dussan.org Git - vaadin-framework.git/commitdiff
Committing Arturs patch to #2840
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Sun, 12 Apr 2009 09:50:09 +0000 (09:50 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Sun, 12 Apr 2009 09:50:09 +0000 (09:50 +0000)
svn changeset:7389/svn branch:6.0

src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java

index 4905b858c5db1a5aa30fa9ced2edc186879d772c..cd4fcae766355a28f829b854904d0ea7e5f990d1 100644 (file)
@@ -17,6 +17,7 @@ import java.lang.reflect.InvocationTargetException;
 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;
@@ -854,10 +855,6 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
          * -----------------------------
          */
 
-        // 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++) {
@@ -916,10 +913,17 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
             /*
              * 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");
@@ -963,9 +967,6 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
             }
         }
         outWriter.print("]"); // Close locales
-
-        // Restore JVM default locale
-        Locale.setDefault(jvmDefault);
     }
 
     /**