Skip to content

Instantly share code, notes, and snippets.

@macsystems
Last active April 14, 2016 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macsystems/44e1e3e56b14dbc1478b8a8cd7ea9254 to your computer and use it in GitHub Desktop.
Save macsystems/44e1e3e56b14dbc1478b8a8cd7ea9254 to your computer and use it in GitHub Desktop.
Timezones problem
@Test
public void timezoneProblem() throws ParseException {
TimeZone utcTime = TimeZone.getTimeZone("UTC");
TimeZone berlinTime = TimeZone.getTimeZone("Europe/Berlin");
Calendar calendar = new GregorianCalendar();
calendar.setTimeZone(utcTime);
int hourOfDay_1 = calendar.get(Calendar.HOUR_OF_DAY);
calendar.setTimeZone(berlinTime);
int hourOfDay_2 = calendar.get(Calendar.HOUR_OF_DAY);
assertEquals("Hours should be not equal as as there are from different timezones:",hourOfDay_1, hourOfDay_2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment