date fix

Patrick Tullmann tullmann at cs.utah.edu
Thu May 13 17:25:41 PDT 1999


Attached is a patch which fixes the odd default formatting of
Date.toString().  (Bug #97)  Basically, none of the default Date
formats (SHORT, MEDIUM, etc) are correct.  So, I constructed an
explicit one for toString().

Another problem noted in that bug (but not fixed) is Kaffe's inability 
to figure out the local timezone.  Use -Duser.timezone=FOO to fix that 
for now...

-Pat

Index: libraries/javalib/java/util/Date.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/util/Date.java,v
retrieving revision 1.9
diff -u -b -u -r1.9 Date.java
--- Date.java	1999/03/28 08:30:15	1.9
+++ Date.java	1999/05/14 00:32:21
@@ -12,8 +12,9 @@
 
 import java.lang.String;
 import java.lang.System;
-import java.text.DateFormat;
 import java.text.ParseException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.io.Serializable;
 
 public class Date implements Serializable, Cloneable
@@ -277,7 +278,8 @@
 }
 
 public String toString() {
-	DateFormat form = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.LONG);
+	// need a string of the form: "Thu May 13 17:52:20 MDT 1999"
+	SimpleDateFormat form = new SimpleDateFormat("E MMM dd HH:mm:ss z yyyy");
 	return (form.format(this));
 }
 }


More information about the kaffe mailing list