summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-16 15:34:46 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-16 15:34:46 +0000
commitdcc6d533c9af5c8c090d6358eb6a20b3beccd92d (patch)
treee90df73370796662a1701f3a31c3381056d62f0e /libjava
parent1893081652b8e2c1ce58d85cbf8dc6a35d256f71 (diff)
downloadgcc-dcc6d533c9af5c8c090d6358eb6a20b3beccd92d.tar.gz
* java/text/SimpleDateFormat.java (parse): Handle non-dst time
zones. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42156 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog5
-rw-r--r--libjava/java/text/SimpleDateFormat.java26
2 files changed, 23 insertions, 8 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index e64825a3085..4bb315f44be 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,8 @@
+2001-05-16 Tom Tromey <tromey@redhat.com>
+
+ * java/text/SimpleDateFormat.java (parse): Handle non-dst time
+ zones.
+
2001-05-15 Tom Tromey <tromey@redhat.com>
* java/util/GregorianCalendar.java (computeTime): Only call
diff --git a/libjava/java/text/SimpleDateFormat.java b/libjava/java/text/SimpleDateFormat.java
index 5b366389c5d..80ab6ea7309 100644
--- a/libjava/java/text/SimpleDateFormat.java
+++ b/libjava/java/text/SimpleDateFormat.java
@@ -518,6 +518,7 @@ public class SimpleDateFormat extends DateFormat
// then this.equals() will no longer have the desired result.
Calendar theCalendar = (Calendar) calendar.clone ();
theCalendar.clear();
+ boolean saw_timezone = false;
int quote_start = -1;
for (; fmt_index < fmt_max; ++fmt_index)
{
@@ -635,7 +636,6 @@ public class SimpleDateFormat extends DateFormat
// We need a special case for the timezone, because it
// uses a different data structure than the other cases.
is_numeric = false;
- // We don't actually use this; see below.
calendar_field = Calendar.DST_OFFSET;
String[][] zoneStrings = formatData.getZoneStrings();
int zoneCount = zoneStrings.length;
@@ -653,8 +653,16 @@ public class SimpleDateFormat extends DateFormat
if (k != strings.length)
{
found_zone = true;
+ saw_timezone = true;
TimeZone tz = TimeZone.getTimeZone (strings[0]);
theCalendar.setTimeZone (tz);
+ theCalendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ());
+ offset = 0;
+ if (k > 2 && tz instanceof SimpleTimeZone)
+ {
+ SimpleTimeZone stz = (SimpleTimeZone) tz;
+ offset = stz.getDSTSavings ();
+ }
pos.setIndex(index + strings[k].length());
break;
}
@@ -698,19 +706,21 @@ public class SimpleDateFormat extends DateFormat
value = i;
}
else
- value = 0;
+ value = offset;
// Assign the value and move on.
- if (calendar_field != Calendar.DST_OFFSET)
- theCalendar.set(calendar_field, value);
+ theCalendar.set(calendar_field, value);
}
try
{
- // Clear calendar fields here to force getTime() to correctly
- // respect DST in the timezone.
- theCalendar.clear (Calendar.DST_OFFSET);
- theCalendar.clear (Calendar.ZONE_OFFSET);
+ if (! saw_timezone)
+ {
+ // Use the real rules to determine whether or not this
+ // particular time is in daylight savings.
+ theCalendar.clear (Calendar.DST_OFFSET);
+ theCalendar.clear (Calendar.ZONE_OFFSET);
+ }
return theCalendar.getTime();
}
catch (IllegalArgumentException x)