Explicitly set DateFormat.is24Hour value needed by tests

Some tests fail under CTS if the device is set to use the 24 hour clock.
The tests that depend on the value of the setting are now being explicit.

Bug: 20899571
Bug: 20937589
Bug: 20939139
Bug: 20378566
Bug: 21585934
Bug: https://code.google.com/p/android/issues/detail?id=162384
(cherry-picked from commit 38a0b85afd4231f46fac59e59ee38729bd5154c4)

Change-Id: Iac9eb15e8bf767bb5f3e96f9ba0486a995eef034
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java
index 0920714..e666c97 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java
@@ -184,6 +184,9 @@
   }
 
   public void test_parseLjava_lang_String() throws ParseException {
+    // This test assumes a default DateFormat.is24Hour setting.
+    DateFormat.is24Hour = null;
+
     String pattern = "A {3, number, currency} B {2, time} C {0, number, percent} D {4}  E {1,choice,0#off|1#on} F {0, date}";
     MessageFormat mf = new MessageFormat(pattern);
     String sToParse = "A $12,345.00 B 9:56:07 AM C 3,200% D 1/15/70 9:56 AM  E on F Jan 1, 1970";
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/Support_MessageFormat.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/Support_MessageFormat.java
index 8003b88..b8b0cee 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/Support_MessageFormat.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/Support_MessageFormat.java
@@ -44,6 +44,8 @@
 	}
 
 	public void t_format_with_FieldPosition() {
+		// This test assumes a default DateFormat.is24Hour setting.
+		DateFormat.is24Hour = null;
 
 		String pattern = "On {4,date} at {3,time}, he ate {2,number, integer} hamburger{2,choice,1#|1<s} and drank {1, number} liters of coke. That was {0,choice,1#just enough|1<more than enough} food!";
 		MessageFormat format = new MessageFormat(pattern, Locale.US);
@@ -71,6 +73,9 @@
 	}
 
 	public void t_formatToCharacterIterator() {
+		// This test assumes a default DateFormat.is24Hour setting.
+		DateFormat.is24Hour = null;
+
 		String pattern = "On {4,date} at {3,time}, he ate {2,number, integer} hamburger{2,choice,1#|1<s} and drank {1, number} liters of coke. That was {0,choice,1#just enough|1<more than enough} food!";
 		MessageFormat format = new MessageFormat(pattern, Locale.US);
 
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/DateTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/DateTest.java
index 0ce971d..f3ad743 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/DateTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/DateTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.harmony.tests.java.util;
 
+import java.text.DateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
@@ -487,18 +488,20 @@
     public void test_toLocaleString() {
         Locale loc = Locale.getDefault();
         Locale.setDefault(Locale.US);
-    TimeZone tz = TimeZone.getDefault();
-    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
-    try {
+        TimeZone tz = TimeZone.getDefault();
+        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+        // This test assumes a default DateFormat.is24Hour setting.
+        DateFormat.is24Hour = null;
+        try {
             assertEquals("Did not convert epoch to GMT string correctly", "Jan 1, 1970 12:00:00 AM",
-                new Date(0).toLocaleString());
+                    new Date(0).toLocaleString());
             assertEquals("Did not convert epoch + 1yr to GMT string correctly",
-                "Jan 1, 1971 12:00:00 AM", new Date((long)365 * 24 * 60 * 60 * 1000)
-                        .toLocaleString());
-    } finally {
+                    "Jan 1, 1971 12:00:00 AM",
+                    new Date((long)365 * 24 * 60 * 60 * 1000).toLocaleString());
+        } finally {
             Locale.setDefault(loc);
-        TimeZone.setDefault(tz);
-    }
+            TimeZone.setDefault(tz);
+        }
     }
 
     static TimeZone defaultTimeZone = TimeZone.getDefault();
diff --git a/luni/src/test/java/libcore/java/text/OldDateFormatTest.java b/luni/src/test/java/libcore/java/text/OldDateFormatTest.java
index df388d3..1bd1d0c 100644
--- a/luni/src/test/java/libcore/java/text/OldDateFormatTest.java
+++ b/luni/src/test/java/libcore/java/text/OldDateFormatTest.java
@@ -86,6 +86,8 @@
      */
     public void test_formatLjava_util_Date() {
         try {
+            // This test assumes a default DateFormat.is24Hour setting.
+            DateFormat.is24Hour = null;
             DateFormat format = DateFormat.getDateTimeInstance(
                     DateFormat.SHORT, DateFormat.SHORT, Locale.US);
             Date current = new Date();
@@ -104,6 +106,8 @@
      */
     public void test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition() {
         try {
+            // This test assumes a default DateFormat.is24Hour setting.
+            DateFormat.is24Hour = null;
             DateFormat format = DateFormat.getDateTimeInstance(
                     DateFormat.SHORT, DateFormat.SHORT, Locale.US);
             Date current = new Date();
@@ -204,6 +208,8 @@
      * java.text.DateFormat#parse(String)
      */
     public void test_parseLString() throws Exception {
+        // This test assumes a default DateFormat.is24Hour setting.
+        DateFormat.is24Hour = null;
         DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.US);
 
         try {