From 98010d02e4963a59049b1f98820a36bf80382cb3 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 24 Mar 2018 21:27:02 +0200 Subject: [PATCH] set default timezone --- .../com/baeldung/dst/DaylightSavingTimeExamplesTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core-java/src/test/java/com/baeldung/dst/DaylightSavingTimeExamplesTest.java b/core-java/src/test/java/com/baeldung/dst/DaylightSavingTimeExamplesTest.java index dbec873eb3..89764d5f84 100644 --- a/core-java/src/test/java/com/baeldung/dst/DaylightSavingTimeExamplesTest.java +++ b/core-java/src/test/java/com/baeldung/dst/DaylightSavingTimeExamplesTest.java @@ -15,11 +15,12 @@ import org.junit.Test; public class DaylightSavingTimeExamplesTest { @Test - public void givenItalianTimeZone_WhenDSTHappens_ThenCorrectlyShiftTimeZone() throws ParseException { + public void givenItalianTimeZone_WhenDSTHappens_ThenCorrectlyShiftTimeZone() throws ParseException { + TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome")); + TimeZone tz = TimeZone.getTimeZone("Europe/Rome"); Calendar cal = Calendar.getInstance(tz, Locale.ITALIAN); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ITALIAN); - df.setTimeZone(tz); Date dateBeforeDST = df.parse("2018-03-25 01:55"); prettyPrint(cal.getTimeZone());