JDK-4059431 : Problem with the SystemTime on a Solaris Machine (Timezone = "WET")
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version:
    3.1,unknown,1.1,1.1.1,1.1.2,1.1.3,1.1.4,1.1.5,1.1.6,1.2.0 3.1,unknown,1.1,1.1.1,1.1.2,1.1.3,1.1.4,1.1.5,1.1.6,1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS:
    generic,solaris_2.5,solaris_2.5.1,solaris_2.6,solaris_9,windows_95,windows_nt generic,solaris_2.5,solaris_2.5.1,solaris_2.6,solaris_9,windows_95,windows_nt
  • CPU: generic,unknown,x86,sparc
  • Submitted: 1997-06-17
  • Updated: 1999-07-20
  • Resolved: 1999-07-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other
1.1.8 1.1.8Fixed 1.2.0Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
Name: mc57594			Date: 06/17/97

I can��t get the right System Time because the TimeZone on the 
Solaries Machine is "WET - West European Time - Zone".
This Time-Zone is not implemented yet.
On NT 4.0 the time is ok!
Can You help me?
Is this a bug?

 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.1.8 generic FIXED IN: 1.1.8 1.2beta4 INTEGRATED IN: 1.1.8 1.2beta4 VERIFIED IN: 1.1.8
14-06-2004

WORK AROUND Name: mc57594 Date: 06/17/97 import java.lang.*; import java.net.*; import java.util.*; import java.text.*; class MyDate extends Date { protected Date aDate; // setzt MyDate auf den uebergebenen Zeitstring public MyDate(String dateString) /*throws ServerException*/ { try { int day = 11; int month = 11; int year = 9999; int hour = 11; int minute = 11; if (!dateString.equals("offen") && !dateString.equals("beliebig") && !dateString.equals("")) { day = Integer.parseInt(dateString.substring(0,2)); month = Integer.parseInt(dateString.substring(2,4)); year = Integer.parseInt(dateString.substring(4,8)); hour = Integer.parseInt(dateString.substring(8,10)); minute = Integer.parseInt(dateString.substring(10,12)); } //System.out.println("hallo" + day+month+year+hour+minute); //set(year,month,day,hour,minute,0); // Format the current time. SimpleDateFormat formatter = new SimpleDateFormat ("dd MM yyyy HH mm"); String dateString_1 = day + " " + month + " " + year + " " + hour + " " + minute; // Parse the previous string back into a Date. ParsePosition pos = new ParsePosition(0); aDate = formatter.parse(dateString_1, pos); } catch (NumberFormatException e) { //throw new ServerException(800); } } // end of checkDateFormat // MyDate ohne parameter setzt MyDate auf die lokale Zeit public MyDate() { TimeZone.setDefault(TimeZone.getTimeZone("EET")); aDate = new Date(System.currentTimeMillis()); } public MyDate(long date) { aDate = new Date(date); } // returns the local System Time // in form of "ddMMyyyyHHmm" public static String getLocalDateTimeString() { TimeZone.setDefault(TimeZone.getTimeZone("EET")); SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyyHHmm"); Date actualTime = new Date(System.currentTimeMillis()); return formatter.format(actualTime); } // getLocalTime public String getDateTimeString() { SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyyHHmm"); //Date time = new Date(getTimeInMillis()); return formatter.format(aDate); } // getDateString public boolean after(MyDate date) { if (aDate.after(date.aDate)) return true; else return false; } // after public boolean before(MyDate date) { if (aDate.before(date.aDate)) return true; else return false; } // after } // end of MyDate ======================================================================
11-06-2004

SUGGESTED FIX Suggested fix for 1.1 --------------------- The line PUTPROP_ForPlatformCString(props, "user.timezone", tzname[0]); is replaced by PUTPROP_ForPlatformCString(props, "user.timezone", search_time_zone()); The function search_time_zone() is implemented in the same file with: static struct _time_zones { char *tz; long offset; char *alias; } time_zones[] = { { "MIT", -11*60*60 } ,{ "HST", -10*60*60 } ,{ "AST", -9*60*60 } ,{ "PST", -8*60*60 } ,{ "PNT", -7*60*60 } ,{ "MST", -7*60*60 } ,{ "CST", -6*60*60 } ,{ "EST", -5*60*60 } ,{ "IET", -5*60*60 } ,{ "PRT", -4*60*60 } ,{ "CNT", -3*60*60-30*60 } ,{ "AGT", -3*60*60 } ,{ "BET", -3*60*60 } ,{ "CAT", -1*60*60 } ,{ "GMT", 0*60*60 } ,{ "ECT", 1*60*60, "MET" } ,{ "ECT", 1*60*60, "WET" } ,{ "EET", 1*60*60 } ,{ "ART", 2*60*60 } ,{ "EAT", 3*60*60 } ,{ "MET", 3*60*60+30*60 } ,{ "NET", 4*60*60 } ,{ "PLT", 5*60*60 } ,{ "IST", 5*60*60+30*60 } ,{ "BST", 6*60*60 } ,{ "VST", 7*60*60 } ,{ "CTT", 8*60*60 } ,{ "JST", 9*60*60 } ,{ "ACT", 9*60*60 + 30*60 } ,{ "AET", 10*60*60 } ,{ "SST", 11*60*60 } ,{ "NST", 12*60*60 } ,{ NULL, 0 } }; static char * search_time_zone(void) { const long off = -timezone; char *name; struct _time_zones *t; name = tzname[0]; /* check for exact match */ for (t = time_zones; t->tz && name; ++t) { if (off == t->offset && strcmp(name, t->tz) == 0) return t->tz; } /* check for known aliases */ for (t = time_zones; t->tz && name; ++t) { if (off == t->offset && t->alias && strcmp(name, t->alias) == 0) return t->tz; } /* check for offset only */ for (t = time_zones; t->tz; ++t) { if (off == t->offset) return t->tz; } return name; }
11-06-2004

EVALUATION SEE ALSO 4074747 4088612 4107380 4069784 -alanl This problem still exists on 1.1.7 and earlier. I must caution licensees that the suggested fix may cause problems. String table lookup has created a lot of problems in the time zone code in the past. There is a more robust way of doing things which is implemented in 1.2 that allows the same code to be used on most Unix platforms (and non-Unix systems, with minor changes). alan.liu@eng 1998-12-17 ----------------------------------------------------------------------- This bug was verified as fixed by the i18n testing team. al.smith@eng 1999-03-17
17-12-1998