Skip to content

Commit

Permalink
Merge pull request eugenp#8290 from kertpjatkin/master
Browse files Browse the repository at this point in the history
BAEL-3302: Fix package name & get rid of 3-letter time zone
  • Loading branch information
JonCook authored Dec 22, 2019
2 parents 05ab180 + 8d2d6d8 commit 9b34837
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.baeldung.timezone;
package com.baeldung.jvmtimezone;

import org.junit.Test;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

import static org.junit.Assert.assertEquals;
Expand All @@ -13,9 +12,7 @@ public class ModifyDefaultTimezoneUnitTest {
@Test
public void givenDefaultTimezoneSet_thenDateTimezoneIsCorrect() {
TimeZone.setDefault(TimeZone.getTimeZone("Portugal"));
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
assertEquals(calendar.getTimeZone(), TimeZone.getTimeZone("Portugal"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.timezone;
package com.baeldung.jvmtimezone;

import org.junit.After;
import org.junit.Before;
Expand All @@ -14,7 +14,7 @@ public class ModifyTimezonePropertyUnitTest {

@Before
public void setup() {
System.setProperty("user.timezone", "IST");
System.setProperty("user.timezone", "Asia/Kolkata");
TimeZone.setDefault(null);
}

Expand All @@ -25,10 +25,8 @@ public void teardown() {

@Test
public void givenTimezonePropertySet_thenDateTimezoneIsCorrect() {
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
assertEquals(calendar.getTimeZone(), TimeZone.getTimeZone("IST"));
assertEquals(calendar.getTimeZone(), TimeZone.getTimeZone("Asia/Kolkata"));
}

}

0 comments on commit 9b34837

Please sign in to comment.