summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui
diff options
context:
space:
mode:
authorSauli Tähkäpää <sauli@vaadin.com>2014-10-04 00:03:38 +0300
committerSauli Tähkäpää <sauli@vaadin.com>2014-11-10 13:20:11 +0200
commitfead7a7435a360776a93df55e5e9ca9e24fa3fd0 (patch)
treead8cef06f5ec6f1db4f4b5ecee4a68bbab44ffe1 /server/src/com/vaadin/ui
parentef8d1ecf8765ce68bbe69021b90f3377ef8d201a (diff)
downloadvaadin-framework-fead7a7435a360776a93df55e5e9ca9e24fa3fd0.tar.gz
vaadin-framework-fead7a7435a360776a93df55e5e9ca9e24fa3fd0.zip
Fix VCalendar to use correct year of week. (#14783)
Change-Id: Id55ad5ed620bd5c187b70ae2a2d0a4c4adea382a
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r--server/src/com/vaadin/ui/Calendar.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/server/src/com/vaadin/ui/Calendar.java b/server/src/com/vaadin/ui/Calendar.java
index 59dfceec9b..92fdce4bd9 100644
--- a/server/src/com/vaadin/ui/Calendar.java
+++ b/server/src/com/vaadin/ui/Calendar.java
@@ -516,7 +516,8 @@ public class Calendar extends AbstractComponent implements
day.date = df_date.format(date);
day.localizedDateFormat = weeklyCaptionFormatter.format(date);
day.dayOfWeek = getDowByLocale(currentCalendar);
- day.week = currentCalendar.get(java.util.Calendar.WEEK_OF_YEAR);
+ day.week = getWeek(currentCalendar);
+ day.yearOfWeek = getYearOfWeek(currentCalendar);
days.add(day);
@@ -560,6 +561,23 @@ public class Calendar extends AbstractComponent implements
state.actions = createActionsList(actionMap);
}
+ private int getWeek(java.util.Calendar calendar) {
+ return calendar.get(java.util.Calendar.WEEK_OF_YEAR);
+ }
+
+ private int getYearOfWeek(java.util.Calendar calendar) {
+ // Would use calendar.getWeekYear() but it's only available since 1.7.
+ int week = getWeek(calendar);
+ int month = calendar.get(java.util.Calendar.MONTH);
+ int year = calendar.get(java.util.Calendar.YEAR);
+
+ if (week == 1 && month == java.util.Calendar.DECEMBER) {
+ return year + 1;
+ }
+
+ return year;
+ }
+
private void setActionsForEachHalfHour(
Map<CalendarDateRange, Set<Action>> actionMap, Date start,
Date end, Action.Handler actionHandler) {
@@ -1768,7 +1786,7 @@ public class Calendar extends AbstractComponent implements
String[] splitted = event.split("w");
if (splitted.length == 2) {
try {
- int yr = 1900 + Integer.parseInt(splitted[0]);
+ int yr = Integer.parseInt(splitted[0]);
int week = Integer.parseInt(splitted[1]);
fireWeekClick(week, yr);
} catch (NumberFormatException e) {