summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2012-04-03 12:25:59 +0100
committerAndrew John Hughes <ahughes@redhat.com>2012-04-03 12:25:59 +0100
commit8d06dfcad3d15670c0b14a447ff93821a8f6e369 (patch)
tree97eb4fe30654890ee8d1fe8a2dad21dbb89972a7
parent639a440219817e5bf9f92c5f1c9d34042ee9d6e1 (diff)
downloadclasspath-8d06dfcad3d15670c0b14a447ff93821a8f6e369.tar.gz
Negate dayOfWeek in java.util.TimeZone.getDateParams.
2007-02-14 Jakub Jelinek <jakub@redhat.com> Andrew Haley <aph@redhat.com> * java/util/TimeZone.java (getDateParams): Negate dayOfWeek. Signed-off-by: Andrew John Hughes <ahughes@redhat.com>
-rw-r--r--ChangeLog5
-rw-r--r--java/util/TimeZone.java24
2 files changed, 23 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 171149052..f8bfb9609 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-02-14 Jakub Jelinek <jakub@redhat.com>
+ Andrew Haley <aph@redhat.com>
+
+ * java/util/TimeZone.java (getDateParams): Negate dayOfWeek.
+
2012-03-22 Andrew John Hughes <ahughes@redhat.com>
* java/util/regex/Matcher.java:
diff --git a/java/util/TimeZone.java b/java/util/TimeZone.java
index ce59c20a6..276602e67 100644
--- a/java/util/TimeZone.java
+++ b/java/util/TimeZone.java
@@ -1151,18 +1151,30 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
int day;
// Month, week of month, day of week
+
+ // "Mm.w.d". d is between 0 (Sunday) and 6. Week w is
+ // between 1 and 5; Week 1 is the first week in which day d
+ // occurs and Week 5 specifies the last d day in the month.
+ // Month m is between 1 and 12.
+
month = Integer.parseInt(date.substring(1, date.indexOf('.')));
int week = Integer.parseInt(date.substring(date.indexOf('.') + 1,
date.lastIndexOf('.')));
int dayOfWeek = Integer.parseInt(date.substring(date.lastIndexOf('.')
+ 1));
- if (week == 5)
- day = -1; // last day of month is -1 in java, 5 in TZ
- else
- // first day of week starting on or after.
- day = (week - 1) * 7 + 1;
+ dayOfWeek++; // Java day of week is one-based, Sunday is first day.
+
+ if (week == 5)
+ day = -1; // last day of month is -1 in java, 5 in TZ
+ else
+ {
+ // First day of week starting on or after. For example,
+ // to specify the second Sunday of April, set month to
+ // APRIL, day-of-month to 8, and day-of-week to -SUNDAY.
+ day = (week - 1) * 7 + 1;
+ dayOfWeek = -dayOfWeek;
+ }
- dayOfWeek++; // Java day of week is one-based, Sunday is first day.
month--; // Java month is zero-based.
return new int[] { month, day, dayOfWeek };
}