re GNATS java.util/47 (Date.toString() returns embedded newline)
Fix for PR java.util/47: * configure, include/config.h: Rebuilt. * configure.in: Don't look for ctime or ctime_r. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Don't mention natDate.cc. * java/util/natDate.cc: Removed. * java/util/TimeZone.java (tzIDs, rawOffsets, timeZones): New static fields. (getAvailableIDs): Rewrote. (getTimeZone): Rewrote. * java/util/Date.java (toGMTString): New method. (toLocaleString): New method. (toString): Rewrote. From-SVN: r29656
This commit is contained in:
parent
aaaec1142d
commit
98e7ae2962
10 changed files with 343 additions and 372 deletions
|
@ -445,10 +445,33 @@ public class Date implements java.io.Serializable, Cloneable
|
|||
+ cal.get(Calendar.DST_OFFSET)/(60*1000));
|
||||
}
|
||||
|
||||
public native String toString ();
|
||||
public String toString ()
|
||||
{
|
||||
// This is slow, but does it matter? There is no particularly
|
||||
// fast way to do it, because we need the timezone offset, which
|
||||
// we don't store. Unix ctime() doesn't provide this information.
|
||||
SimpleDateFormat fmt = new SimpleDateFormat ("E MMM dd HH:mm:ss z yyyy",
|
||||
Locale.US);
|
||||
fmt.setTimeZone(TimeZone.getDefault());
|
||||
return fmt.format(this);
|
||||
}
|
||||
|
||||
// TODO: toLocaleString
|
||||
// TODO: toGMTString
|
||||
public String toGMTString ()
|
||||
{
|
||||
// This method is deprecated. We don't care if it is very slow.
|
||||
SimpleDateFormat fmt = new SimpleDateFormat ("d MMM yyyy HH:mm:ss 'GMT'",
|
||||
Locale.US);
|
||||
fmt.setTimeZone(TimeZone.zoneGMT);
|
||||
return fmt.format(this);
|
||||
}
|
||||
|
||||
public String toLocaleString ()
|
||||
{
|
||||
// This method is deprecated. We don't care if it is very slow.
|
||||
DateFormat fmt = DateFormat.getDateTimeInstance();
|
||||
fmt.setTimeZone(TimeZone.getDefault());
|
||||
return fmt.format(this);
|
||||
}
|
||||
|
||||
public static long UTC (int year, int month, int date,
|
||||
int hours, int minutes, int seconds)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue