0

This simple function returns different time strings for my Win 7 vs XP systems, even though both systems are in the same time zone (Germany) having the same system time.

private static String timeNow() {
    Calendar cal = Calendar.getInstance();
    return sdfTime.format(cal.getTime());
}

with

private static final DateFormat sdfTime = new SimpleDateFormat("HH:mm");

they return a time exactly 2h different (this function returns system time -2h on my XP system). I tried to counteract this problem by setting sdfTime.setTimeZone(TimeZone.getTimeZone("Germany")) which did not help.

Why is this difference and how can I fix it?

Thanks a lot in advance.

dotwin
  • 1,302
  • 2
  • 11
  • 31

0 Answers0