Date related problems
Gerhard Paulus
gpaulus at stud.uni-frankfurt.de
Wed Dec 30 02:59:24 PST 1998
in Sun's VM "month" for Date and Calendar is zero-based. In Kaffe
"month" seems to be generally 1-based but 12 is not and month 0 is
accepted. There seem to be problems with 31 day months, too.
In SimpleDateFormat the "HH" template as in "yyyy.MM.dd HH:mm:ss" does
not work right und should be 2 digits.
Calendar.getInstance(TimeZone, Locale) seems to have problems with "GMT"
timezone.
Please run the following code which will show some bugs /
inconsistencies.
SimpleDateFormat dateFormat = new
SimpleDateFormat("yyyy.MM.dd", Locale.US) ;
SimpleDateFormat dateTimeFormat = new
SimpleDateFormat("yyyy.MM.dd HH:mm:ss", Locale.US) ;
Date date= null ;
TimeZone tz= TimeZone.getDefault() ;
tz.setRawOffset(0) ;
Calendar cal= Calendar.getInstance(tz, Locale.US) ;
cal.set(1998,0,15) ; // 1998.00.15
date= cal.getTime() ;
System.out.println("temp: dateFormat: "+dateFormat.format(date)) ;
// Kaffe Sun
// cal.set(1998,0,15) ; // 1998.00.15 1998.01.15
// cal.set(1998,8,31) ; // 1998.09.01 1998.10.01
// cal.set(1998,11,15) ; // 1998.11.15 1998.12.15
// cal.set(1998,12,15) ; // 1999.00.15 1999.01.15
// cal.set(1998,11,15, 1,1,1) ;
// 1998.11.15 1:01:01 1998.12.15 02:01:01
// cal.set(1998,11,11, 3,15,10);
// 1998.11.11 1:15:10 1998.12.11 04:15:10
// ----------
// this will not return a Calendar instance :
TimeZone tz= TimeZone.getTimeZone("GMT") ;
Calendar cal= Calendar.getInstance(tz, Locale.US) ;
More information about the kaffe
mailing list