diff --git a/tests/src/test/java/org/teavm/classlib/java/text/DateFormatTest.java b/tests/src/test/java/org/teavm/classlib/java/text/DateFormatTest.java index 6e2fcbbb8..047956c0d 100644 --- a/tests/src/test/java/org/teavm/classlib/java/text/DateFormatTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/text/DateFormatTest.java @@ -22,6 +22,7 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; +import java.util.TimeZone; import org.junit.Test; /** @@ -29,6 +30,10 @@ import org.junit.Test; * @author Alexey Andreev */ public class DateFormatTest { + public DateFormatTest() { + TimeZone.setDefault(TimeZone.getTimeZone("GMT")); + } + @Test public void shortDateFormatHandled() throws ParseException { DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT, Locale.ENGLISH); diff --git a/tests/src/test/java/org/teavm/classlib/java/text/SimpleDateFormatTest.java b/tests/src/test/java/org/teavm/classlib/java/text/SimpleDateFormatTest.java index 8a87fec0b..d58618a4c 100644 --- a/tests/src/test/java/org/teavm/classlib/java/text/SimpleDateFormatTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/text/SimpleDateFormatTest.java @@ -26,6 +26,10 @@ import org.junit.Test; * @author Alexey Andreev */ public class SimpleDateFormatTest { + public SimpleDateFormatTest() { + TimeZone.setDefault(TimeZone.getTimeZone("GMT")); + } + @Test public void firstDayOfWeekMatches() { assertEquals(Calendar.SUNDAY, new GregorianCalendar(Locale.ENGLISH).getFirstDayOfWeek()); @@ -135,15 +139,15 @@ public class SimpleDateFormatTest { private Date getDateWithZoneOffset(long milliseconds) { Calendar calendar = new GregorianCalendar(Locale.ENGLISH); + calendar.setTimeZone(TimeZone.getTimeZone("GMT")); calendar.setTimeInMillis(milliseconds); - milliseconds -= calendar.get(Calendar.ZONE_OFFSET); - milliseconds -= calendar.get(Calendar.DST_OFFSET); return new Date(milliseconds); } private long getTimeWithoutZoneOffset(Date date) { Calendar calendar = new GregorianCalendar(Locale.ENGLISH); + calendar.setTimeZone(TimeZone.getTimeZone("GMT")); calendar.setTime(date); - return calendar.getTimeInMillis() + calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET); + return calendar.getTimeInMillis(); } }