re PR libgcj/1358 (java.util.Date.toString() doesn't seem to behave properly.)
Fix for PR libgcj/1358: * java/lang/System.java: Update Copyright date properly. * java/util/Calendar.java: Fix typo in comment. (set): Set 24-hour clock hour instead of 12-hour clock hour. * java/util/GregorianCalendar.java (GregorianCalendar): Properly initialize times. Spec says to set H:M:S values to zero only if a date is given. * java/util/TimeZone.java (getDefaultDisplayName): Casts to char needed for evaluating numbers '0' to '9' in printouts of GMT offsets. * java/util/natGregorianCalendar.cc (computeTime): Properly handle timezones and GMT offsets, being careful to account for units of milliseconds vs. seconds. From-SVN: r38508
This commit is contained in:
parent
5da1e2c489
commit
ed55bdc47f
6 changed files with 30 additions and 16 deletions
|
@ -1,3 +1,18 @@
|
||||||
|
2000-12-27 Warren Levy <warrenl@redhat.com>
|
||||||
|
|
||||||
|
Fix for PR libgcj/1358:
|
||||||
|
* java/lang/System.java: Update Copyright date properly.
|
||||||
|
* java/util/Calendar.java: Fix typo in comment.
|
||||||
|
(set): Set 24-hour clock hour instead of 12-hour clock hour.
|
||||||
|
* java/util/GregorianCalendar.java (GregorianCalendar): Properly
|
||||||
|
initialize times. Spec says to set H:M:S values to zero only if
|
||||||
|
a date is given.
|
||||||
|
* java/util/TimeZone.java (getDefaultDisplayName): Casts to char
|
||||||
|
needed for evaluating numbers '0' to '9' in printouts of GMT offsets.
|
||||||
|
* java/util/natGregorianCalendar.cc (computeTime): Properly handle
|
||||||
|
timezones and GMT offsets, being careful to account for units of
|
||||||
|
milliseconds vs. seconds.
|
||||||
|
|
||||||
2000-12-28 Bryce McKinlay <bryce@albatross.co.nz>
|
2000-12-28 Bryce McKinlay <bryce@albatross.co.nz>
|
||||||
|
|
||||||
* java/lang/natClass.cc (_Jv_IsAssignableFrom): Primitive TYPEs can
|
* java/lang/natClass.cc (_Jv_IsAssignableFrom): Primitive TYPEs can
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// System.java - System-specific info.
|
// System.java - System-specific info.
|
||||||
|
|
||||||
/* Copyright (C) 1998, 1999 Free Software Foundation
|
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
|
||||||
|
|
||||||
This file is part of libgcj.
|
This file is part of libgcj.
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ public abstract class Calendar implements Serializable, Cloneable
|
||||||
*/
|
*/
|
||||||
public static final int DECEMBER = 11;
|
public static final int DECEMBER = 11;
|
||||||
/**
|
/**
|
||||||
* Constant representing Undecimber. This is an artifical name useful
|
* Constant representing Undecimber. This is an artificial name useful
|
||||||
* for lunar calendars.
|
* for lunar calendars.
|
||||||
*/
|
*/
|
||||||
public static final int UNDECIMBER = 12;
|
public static final int UNDECIMBER = 12;
|
||||||
|
@ -581,9 +581,9 @@ public abstract class Calendar implements Serializable, Cloneable
|
||||||
public final void set(int year, int month, int date, int hour, int minute)
|
public final void set(int year, int month, int date, int hour, int minute)
|
||||||
{
|
{
|
||||||
set(year, month, date);
|
set(year, month, date);
|
||||||
fields[HOUR] = hour;
|
fields[HOUR_OF_DAY] = hour;
|
||||||
fields[MINUTE] = minute;
|
fields[MINUTE] = minute;
|
||||||
isSet[HOUR] = isSet[MINUTE] = true;
|
isSet[HOUR_OF_DAY] = isSet[MINUTE] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -115,23 +115,20 @@ public class GregorianCalendar extends Calendar {
|
||||||
public GregorianCalendar (int year, int month, int date)
|
public GregorianCalendar (int year, int month, int date)
|
||||||
{
|
{
|
||||||
this();
|
this();
|
||||||
setDefaultTime ();
|
set (year, month, date, 0, 0, 0);
|
||||||
set (year, month, date);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GregorianCalendar (int year, int month, int date,
|
public GregorianCalendar (int year, int month, int date,
|
||||||
int hour, int minute)
|
int hour, int minute)
|
||||||
{
|
{
|
||||||
this();
|
this();
|
||||||
setDefaultTime ();
|
set (year, month, date, hour, minute, 0);
|
||||||
set (year, month, date, hour, minute);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GregorianCalendar (int year, int month, int date,
|
public GregorianCalendar (int year, int month, int date,
|
||||||
int hour, int minute, int second)
|
int hour, int minute, int second)
|
||||||
{
|
{
|
||||||
this();
|
this();
|
||||||
setDefaultTime ();
|
|
||||||
set (year, month, date, hour, minute, second);
|
set (year, month, date, hour, minute, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -896,8 +896,9 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
|
||||||
int hours = offset / 60;
|
int hours = offset / 60;
|
||||||
int minutes = offset % 60;
|
int minutes = offset % 60;
|
||||||
|
|
||||||
sb.append('0' + hours / 10).append('0' + hours % 10).append(':');
|
sb.append((char) ('0' + hours / 10)).append((char) ('0' + hours % 10));
|
||||||
sb.append('0' + minutes / 10).append('0' + minutes % 10);
|
sb.append(':');
|
||||||
|
sb.append((char) ('0' + minutes / 10)).append((char) ('0' + minutes % 10));
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,16 +39,17 @@ java::util::GregorianCalendar::computeTime ()
|
||||||
// Adjust for local timezone (introduced by mktime) and our
|
// Adjust for local timezone (introduced by mktime) and our
|
||||||
// timezone.
|
// timezone.
|
||||||
#if defined (STRUCT_TM_HAS_GMTOFF)
|
#if defined (STRUCT_TM_HAS_GMTOFF)
|
||||||
t += tim.tm_gmtoff;
|
t -= tim.tm_gmtoff;
|
||||||
#elif defined (HAVE_TIMEZONE)
|
#elif defined (HAVE_TIMEZONE)
|
||||||
t -= timezone;
|
t += timezone;
|
||||||
#endif
|
#endif
|
||||||
java::util::TimeZone *zone = getTimeZone ();
|
|
||||||
t += zone->getRawOffset();
|
|
||||||
|
|
||||||
// Adjust for milliseconds.
|
// Adjust for milliseconds.
|
||||||
time = t * (jlong) 1000 + elements(fields)[MILLISECOND];
|
time = t * (jlong) 1000 + elements(fields)[MILLISECOND];
|
||||||
|
|
||||||
|
// Now adjust for the real timezone, i.e. our timezone, which is in millis.
|
||||||
|
java::util::TimeZone *zone = getTimeZone ();
|
||||||
|
time += zone->getRawOffset();
|
||||||
|
|
||||||
isTimeSet = true;
|
isTimeSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue