gpt4 book ai didi

java - Vaadin datepicker翻译月份

转载 作者:行者123 更新时间:2023-12-05 09:27:18 31 4
gpt4 key购买 nike

有没有办法让日期选择器以默认英语以外的其他语言显示月份?

例如在德语/DE 中将它设置为将 June 显示为 Juni ?

最佳答案

您可以通过设置 I18N-ize DatePickersetI18n(DatePicker.DatePickerI18n) 值。例如

def datePicker = new DatePicker().tap {
setI18n(new DatePicker.DatePickerI18n().tap {
def locale = Locale.GERMAN

// date formats
setDateFormats(
DateTimeFormatterBuilder.getLocalizedDateTimePattern(
FormatStyle.MEDIUM,
null,
IsoChronology.INSTANCE,
locale
).replace('y', 'yyyy'),
// this would be useful in theory, but is not in practice, because the first format always wins
DateTimeFormatterBuilder.getLocalizedDateTimePattern(
FormatStyle.SHORT,
null,
IsoChronology.INSTANCE,
locale
)
)

// days
def daysOfWeek = [DayOfWeek.SUNDAY] + DayOfWeek.values().toList() // sunday first, because ISO is a joke for some
setWeekdays(daysOfWeek*.getDisplayName(TextStyle.FULL, locale))
setWeekdaysShort(daysOfWeek*.getDisplayName(TextStyle.SHORT, locale))
setFirstDayOfWeek(WeekFields.of(locale).firstDayOfWeek.value % 7) // this works because, because value is + 1

// months
setMonthNames(Month.values()*.getDisplayName(TextStyle.FULL, locale))

// words (use your translation backend here)
setWeek("Woche")
setToday("Heute")
setCancel("Abbrechen")
})
addValueChangeListener{
Notification.show(it.value.toString())
}
}

关于java - Vaadin datepicker翻译月份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72649916/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com