Run sample code below on some locale like ja.
Expected outputs are:(generated on Solaris)
Stringified Epoch:Thu Jan 01 09:00:00 GMT+09:00 1970
Stringified current time:Thu Mar 13 15:25:37 GMT+09:00 1997
Formatted Epoch:70/01/01 09:00:00
Formatted current time:97/03/13 15:25:37
formatter TimeZone JST
default calendar's TimeZone JST
TimeZone default's TimeZone JST
Outputs on Win32 were:
Stringified Epoch:Thu Jan 01 00:00:00 GMT+00:00 1970
Stringified current time:Tue Mar 11 09:50:57 GMT+00:00 1997
Formatted Epoch:70/01/01 09:00:00
Formatted current time:97/03/11 18:50:57
formatter TimeZone JST
default calendar's TimeZone GMT
TimeZone default's TimeZone GMT
See default Timezone, it's GMT instead of JST.
Sample:
mport java.text.DateFormat;
import java.util.*;
public class DateKimiko {
public static void main(String args[]) {
DateFormat f = DateFormat.getDateTimeInstance();
Date d0 = new Date(0L), d1 = new Date();
Calendar cur = Calendar.getInstance();
System.out.println("Stringified Epoch:" + d0);
System.out.println("Stringified current time:" + d1);
System.out.println("Formatted Epoch:" + f.format(d0));
System.out.println("Formatted current time:" + f.format(d1));
System.out.println("formatter TimeZone " + f.getTimeZone().getID());
System.out.println("default calendar's TimeZone " + cur.getTimeZone().getID());
System.out.println("TimeZone default's TimeZone " + TimeZone.getDefault().getID());
/*
String dz[][] = data.getZoneStrings();
for(int i = 0; i < dz.length; i++) {
for(int j = 0; j < dz[i].length; j++) {
System.out.println("Data[" + i + "][" + j + "] = " + dz[i][j]);
}
}
*/
}
}
allan.jacobs@Eng 1997-05-23
The test java_util/GregorianCalendar/index.html#isLeapYear fails on Solaris
machines too.
==========================================================================
daniel.indrigo@Canada 1997-09-19 This sounds like the same problem
TimeZone.getDefault () and
DateFormat.getInstance().getTimeZone() both
return wrong (and mostly different) timezones.
TimeZone.getDefault ():
When switching between timezones in the Date/Time
control panel, TimeZone.getDefault () returns
the correct time zone for some settings but
mostly it returns GMT.
A setting of
"(GMT+01:00) Berlin, Stockholm, Rome, Bern, Brussels, Vienna, Amsterdam"
makes TimeZone.getDefault () return GMT (wrong!)
but choosing
"(GMT+01:00) Paris, Madrid"
makes TimeZone.getDefault () return ECT (correct)
DateFormat.getInstance().getTimeZone():
Seems to return timezones based on the settings
in the Regional Settings control panel, allthough
it does get it wrong.
Choose Afrikaans and it returns PST!
Choose Sweden and it correctly returns ECT
I have tested both Windows NT 4.0 and Windows 95
using JDK 1.1.2 and 1.1.4, with the same results.
To reproduce the problems, try different
settings in the Time/Date and Regional Settings
control panels and run the following program:
import java.lang.*;
import java.util.*;
import java.text.*;
class TimeZoneTest extends Object
{
public static void main (String [] args)
{
Date d = new Date ();
Calendar c = Calendar.getInstance ();
c.setTime (d);
TimeZone tz = TimeZone.getDefault ();
System.out.println ();
System.out.println ("TimeZone returned by TimeZone.getDefault ()");
System.out.println (" TimeZone ID: " + tz.getID());
System.out.println (" Raw Timezone Offset: " + (tz.getRawOffset () / 3600000) + " hour(s)");
System.out.println (" Uses Daylight Time: " + tz.useDaylightTime ());
System.out.println (" In Daylight Time: " + tz.inDaylightTime (d));
System.out.println (" Current Offset " + (tz.getOffset (
c.get (Calendar.ERA), c.get (Calendar.YEAR),
c.get (Calendar.MONTH), c.get (Calendar.DAY_OF_MONTH),
c.get (Calendar.DAY_OF_WEEK), c.get (Calendar.MILLISECOND))/3600000)
+ " hour(s)");
tz = DateFormat.getInstance ().getTimeZone ();
System.out.println ();
System.out.println ("TimeZone returned by DateFormat.getInstance ().getTimeZone ()");
System.out.println (" TimeZone ID: " + tz.getID());
System.out.println (" Raw Timezone Offset: " + (tz.getRawOffset () / 3600000) + " hour(s)");
System.out.println (" Uses Daylight Time: " + tz.useDaylightTime ());
System.out.println (" In Daylight Time: " + tz.inDaylightTime (d));
System.out.println (" Current Offset " + (tz.getOffset (
c.get (Calendar.ERA), c.get (Calendar.YEAR),
c.get (Calendar.MONTH), c.get (Calendar.DAY_OF_MONTH),
c.get (Calendar.DAY_OF_WEEK), c.get (Calendar.MILLISECOND)) / 3600000)
+ " hour(s)");
}
}
===============================================================================
Expected outputs are:(generated on Solaris)
Stringified Epoch:Thu Jan 01 09:00:00 GMT+09:00 1970
Stringified current time:Thu Mar 13 15:25:37 GMT+09:00 1997
Formatted Epoch:70/01/01 09:00:00
Formatted current time:97/03/13 15:25:37
formatter TimeZone JST
default calendar's TimeZone JST
TimeZone default's TimeZone JST
Outputs on Win32 were:
Stringified Epoch:Thu Jan 01 00:00:00 GMT+00:00 1970
Stringified current time:Tue Mar 11 09:50:57 GMT+00:00 1997
Formatted Epoch:70/01/01 09:00:00
Formatted current time:97/03/11 18:50:57
formatter TimeZone JST
default calendar's TimeZone GMT
TimeZone default's TimeZone GMT
See default Timezone, it's GMT instead of JST.
Sample:
mport java.text.DateFormat;
import java.util.*;
public class DateKimiko {
public static void main(String args[]) {
DateFormat f = DateFormat.getDateTimeInstance();
Date d0 = new Date(0L), d1 = new Date();
Calendar cur = Calendar.getInstance();
System.out.println("Stringified Epoch:" + d0);
System.out.println("Stringified current time:" + d1);
System.out.println("Formatted Epoch:" + f.format(d0));
System.out.println("Formatted current time:" + f.format(d1));
System.out.println("formatter TimeZone " + f.getTimeZone().getID());
System.out.println("default calendar's TimeZone " + cur.getTimeZone().getID());
System.out.println("TimeZone default's TimeZone " + TimeZone.getDefault().getID());
/*
String dz[][] = data.getZoneStrings();
for(int i = 0; i < dz.length; i++) {
for(int j = 0; j < dz[i].length; j++) {
System.out.println("Data[" + i + "][" + j + "] = " + dz[i][j]);
}
}
*/
}
}
allan.jacobs@Eng 1997-05-23
The test java_util/GregorianCalendar/index.html#isLeapYear fails on Solaris
machines too.
==========================================================================
daniel.indrigo@Canada 1997-09-19 This sounds like the same problem
TimeZone.getDefault () and
DateFormat.getInstance().getTimeZone() both
return wrong (and mostly different) timezones.
TimeZone.getDefault ():
When switching between timezones in the Date/Time
control panel, TimeZone.getDefault () returns
the correct time zone for some settings but
mostly it returns GMT.
A setting of
"(GMT+01:00) Berlin, Stockholm, Rome, Bern, Brussels, Vienna, Amsterdam"
makes TimeZone.getDefault () return GMT (wrong!)
but choosing
"(GMT+01:00) Paris, Madrid"
makes TimeZone.getDefault () return ECT (correct)
DateFormat.getInstance().getTimeZone():
Seems to return timezones based on the settings
in the Regional Settings control panel, allthough
it does get it wrong.
Choose Afrikaans and it returns PST!
Choose Sweden and it correctly returns ECT
I have tested both Windows NT 4.0 and Windows 95
using JDK 1.1.2 and 1.1.4, with the same results.
To reproduce the problems, try different
settings in the Time/Date and Regional Settings
control panels and run the following program:
import java.lang.*;
import java.util.*;
import java.text.*;
class TimeZoneTest extends Object
{
public static void main (String [] args)
{
Date d = new Date ();
Calendar c = Calendar.getInstance ();
c.setTime (d);
TimeZone tz = TimeZone.getDefault ();
System.out.println ();
System.out.println ("TimeZone returned by TimeZone.getDefault ()");
System.out.println (" TimeZone ID: " + tz.getID());
System.out.println (" Raw Timezone Offset: " + (tz.getRawOffset () / 3600000) + " hour(s)");
System.out.println (" Uses Daylight Time: " + tz.useDaylightTime ());
System.out.println (" In Daylight Time: " + tz.inDaylightTime (d));
System.out.println (" Current Offset " + (tz.getOffset (
c.get (Calendar.ERA), c.get (Calendar.YEAR),
c.get (Calendar.MONTH), c.get (Calendar.DAY_OF_MONTH),
c.get (Calendar.DAY_OF_WEEK), c.get (Calendar.MILLISECOND))/3600000)
+ " hour(s)");
tz = DateFormat.getInstance ().getTimeZone ();
System.out.println ();
System.out.println ("TimeZone returned by DateFormat.getInstance ().getTimeZone ()");
System.out.println (" TimeZone ID: " + tz.getID());
System.out.println (" Raw Timezone Offset: " + (tz.getRawOffset () / 3600000) + " hour(s)");
System.out.println (" Uses Daylight Time: " + tz.useDaylightTime ());
System.out.println (" In Daylight Time: " + tz.inDaylightTime (d));
System.out.println (" Current Offset " + (tz.getOffset (
c.get (Calendar.ERA), c.get (Calendar.YEAR),
c.get (Calendar.MONTH), c.get (Calendar.DAY_OF_MONTH),
c.get (Calendar.DAY_OF_WEEK), c.get (Calendar.MILLISECOND)) / 3600000)
+ " hour(s)");
}
}
===============================================================================
- duplicates
-
JDK-4083167 Date is wrong after transitioning from PDT to PST
-
- Closed
-