diff options
author | Artur Signell <artur@vaadin.com> | 2015-09-03 10:34:03 +0300 |
---|---|---|
committer | Mika Murtojarvi <mika@vaadin.com> | 2015-09-09 18:01:23 +0300 |
commit | cc2078de2a9720426fde2634729cbaf1b3476f62 (patch) | |
tree | c12e117e24a1125a4e0fcb5804bd73b3e77a99d0 /server | |
parent | 1c47ed4f9296e53fc2b4d56ebbfebc0cb6d0c0aa (diff) | |
download | vaadin-framework-cc2078de2a9720426fde2634729cbaf1b3476f62.tar.gz vaadin-framework-cc2078de2a9720426fde2634729cbaf1b3476f62.zip |
Use correct month names with Java 8 (#18760)
Change-Id: I4dcb1f172339005947fa45924792ab86d0952b90
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/server/LocaleService.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/server/src/com/vaadin/server/LocaleService.java b/server/src/com/vaadin/server/LocaleService.java index 0274d227ab..ccdc49f690 100644 --- a/server/src/com/vaadin/server/LocaleService.java +++ b/server/src/com/vaadin/server/LocaleService.java @@ -23,6 +23,7 @@ import java.io.Serializable; import java.text.DateFormat; import java.text.DateFormatSymbols; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Locale; import java.util.logging.Logger; @@ -120,9 +121,24 @@ public class LocaleService implements Serializable { LocaleData localeData = new LocaleData(); localeData.name = locale.toString(); + Calendar c = Calendar.getInstance(locale); + c.set(2015, 0, 1); + SimpleDateFormat shortMonthFormat = new SimpleDateFormat("MMM", locale); + SimpleDateFormat longMonthFormat = new SimpleDateFormat("MMMM", locale); + + int monthsInYear = c.getMaximum(Calendar.MONTH) + 1; + localeData.shortMonthNames = new String[monthsInYear]; + localeData.monthNames = new String[monthsInYear]; + for (int month = 0; month < monthsInYear; month++) { + c.set(Calendar.MONTH, month); + String shortMonth = shortMonthFormat.format(c.getTime()); + String longMonth = longMonthFormat.format(c.getTime()); + localeData.shortMonthNames[month] = shortMonth; + localeData.monthNames[month] = longMonth; + } + final DateFormatSymbols dfs = new DateFormatSymbols(locale); - localeData.shortMonthNames = dfs.getShortMonths(); - localeData.monthNames = dfs.getMonths(); + // Client expects 0 based indexing, DateFormatSymbols use 1 based localeData.shortDayNames = new String[7]; localeData.dayNames = new String[7]; |