如何让 GWT DatePicker 使用星期一作为一周的第一天? [英] How to make GWT DatePicker to use Monday as the first day of the week?
问题描述
差不多,正如标题所说.我需要让 GWT DatePicker 组件使用星期一作为一周的第一天.目前日标签是S M T W T F S
,我希望它是M T W T F S S
.有什么办法可以实现吗?
Pretty much, what the title says. I need to make the GWT DatePicker component use Monday as the first day of the week. Currently the day labels are S M T W T F S
, I want it to be M T W T F S S
. Any way to accomplish it?
推荐答案
如果自动区域设置检测不符合您的需求(并且可能编辑 com.google.gwt 中的
也不会),唯一的选择是修改 DatePicker 的实现:firstDayOfTheWeek
.i18n.client.constants.DateTimeConstantsImpl_xy.properties
If the automatic locale detection doesn't fit your needs (and probably editing the firstDayOfTheWeek
in com.google.gwt.i18n.client.constants.DateTimeConstantsImpl_xy.properties
won't be either), the only option would be to modify the implementation of DatePicker:
扩展 DatePicker,编写一个新的构造函数,它使用您自己的视图和模型调用受保护的
DatePicker(MonthSelector monthSelector, CalendarView view, CalendarModel model)
构造函数.
CalendarModel 可以扩展,因此您必须覆盖 getCurrentFirstDayOfFirstWeek
.
The CalendarModel can be extended, so you'd have to override getCurrentFirstDayOfFirstWeek
.
DefaultCalendarView
是最终的,因此您必须将其复制到一个新类并修改其 setup
方法.
The DefaultCalendarView
is final, so you'd have to copy it to a new class and modify its setup
method.
这很混乱,这就是 GWT 的一个小缺点——它大量使用单例而不是依赖注入......
It's quite messy, and that's the little downside of GWT - it makes heavy use of Singletons instead of Dependency Injection...
这篇关于如何让 GWT DatePicker 使用星期一作为一周的第一天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!