Name: mc57594 Date: 05/16/97
I use JDK1.1.1 on Windows 95 / NT (same problem with 1.1FCS)
I run the program at the end of the page.
If I have my OS-timezone to, for example, western europe,
getTimeInstance returns PST time on '95, the right time on
NT.
If I include the TimeZone.getDefault lines, I get GMT time
(Western Europe is GMT+1), both on '95 and NT
If I run java with -Duser.timezone=ECT, both lines return the
right time, both on '95 and NT
import java.text.DateFormat;
import java.util.TimeZone;
import java.util.Date;
public class DateTest {
public static void main(String args[]) {
Date now = new Date();
DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.FULL);
String dateTimeString = dateFormat.format(now);
System.out.println("getTimeInstance returns : " + dateTimeString);
dateFormat.setTimeZone(TimeZone.getDefault());
dateTimeString = dateFormat.format(now);
System.out.println("Timezone.getDefault returns : " + dateTimeString);
}
}
======================================================================
- duplicates
-
JDK-4069784 TimeZone.getDefault() returns incorrect time zome.
-
- Closed
-