summaryrefslogtreecommitdiffstats
path: root/luni/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/test')
-rw-r--r--luni/src/test/java/libcore/java/text/OldSimpleDateFormatTest.java18
-rw-r--r--luni/src/test/java/libcore/java/util/TimeZoneTest.java11
2 files changed, 26 insertions, 3 deletions
diff --git a/luni/src/test/java/libcore/java/text/OldSimpleDateFormatTest.java b/luni/src/test/java/libcore/java/text/OldSimpleDateFormatTest.java
index 4da54e6..cbcf7e9 100644
--- a/luni/src/test/java/libcore/java/text/OldSimpleDateFormatTest.java
+++ b/luni/src/test/java/libcore/java/text/OldSimpleDateFormatTest.java
@@ -387,12 +387,24 @@ public class OldSimpleDateFormatTest extends junit.framework.TestCase {
FormatTester test = new FormatTester();
Calendar cal = new GregorianCalendar(1999, Calendar.JUNE, 2, 15, 3, 6);
- format.setTimeZone(new SimpleTimeZone(60000, "ONE MINUTE"));
+ TimeZone tz0001 = new SimpleTimeZone(60000, "ONE MINUTE");
+ TimeZone tz0130 = new SimpleTimeZone(5400000, "ONE HOUR, THIRTY");
+ TimeZone tzMinus0130 = new SimpleTimeZone(-5400000, "NEG ONE HOUR, THIRTY");
+
+ format.setTimeZone(tz0001);
+ test.test(" Z", cal, " +0001", DateFormat.TIMEZONE_FIELD);
+ test.test(" ZZZZ", cal, " +0001", DateFormat.TIMEZONE_FIELD);
+ format.setTimeZone(tz0130);
+ test.test(" Z", cal, " +0130", DateFormat.TIMEZONE_FIELD);
+ format.setTimeZone(tzMinus0130);
+ test.test(" Z", cal, " -0130", DateFormat.TIMEZONE_FIELD);
+
+ format.setTimeZone(tz0001);
test.test(" z", cal, " GMT+00:01", DateFormat.TIMEZONE_FIELD);
test.test(" zzzz", cal, " GMT+00:01", DateFormat.TIMEZONE_FIELD);
- format.setTimeZone(new SimpleTimeZone(5400000, "ONE HOUR, THIRTY"));
+ format.setTimeZone(tz0130);
test.test(" z", cal, " GMT+01:30", DateFormat.TIMEZONE_FIELD);
- format.setTimeZone(new SimpleTimeZone(-5400000, "NEG ONE HOUR, THIRTY"));
+ format.setTimeZone(tzMinus0130);
test.test(" z", cal, " GMT-01:30", DateFormat.TIMEZONE_FIELD);
format.setTimeZone(TimeZone.getTimeZone("America/New_York"));
diff --git a/luni/src/test/java/libcore/java/util/TimeZoneTest.java b/luni/src/test/java/libcore/java/util/TimeZoneTest.java
index dbde4ac..f7fe649 100644
--- a/luni/src/test/java/libcore/java/util/TimeZoneTest.java
+++ b/luni/src/test/java/libcore/java/util/TimeZoneTest.java
@@ -17,6 +17,7 @@
package libcore.java.util;
import java.util.Date;
+import java.util.Locale;
import java.util.TimeZone;
import java.util.SimpleTimeZone;
@@ -40,4 +41,14 @@ public class TimeZoneTest extends junit.framework.TestCase {
stz.inDaylightTime(new Date());
stz.clone();
}
+
+ // http://b/3049014
+ public void testCustomTimeZoneDisplayNames() {
+ TimeZone tz0001 = new SimpleTimeZone(60000, "ONE MINUTE");
+ TimeZone tz0130 = new SimpleTimeZone(5400000, "ONE HOUR, THIRTY");
+ TimeZone tzMinus0130 = new SimpleTimeZone(-5400000, "NEG ONE HOUR, THIRTY");
+ assertEquals("GMT+00:01", tz0001.getDisplayName(false, TimeZone.SHORT, Locale.US));
+ assertEquals("GMT+01:30", tz0130.getDisplayName(false, TimeZone.SHORT, Locale.US));
+ assertEquals("GMT-01:30", tzMinus0130.getDisplayName(false, TimeZone.SHORT, Locale.US));
+ }
}