How to make GWT DatePicker to use Monday as the first day of the week?

前端 未结 3 1225
Happy的楠姐
Happy的楠姐 2020-12-30 12:16

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

3条回答
  •  隐瞒了意图╮
    2020-12-30 12:42

    If you look at the source code of DefaultCalendarView (which can be provided in the protected constructor of a DatePicker) it uses CalendarUtil's getStartingDayOfWeek to set the default starting day. CalendarUtil gets the start date from DateTimeConstants. So, as ju said, it's determined by your locale.

    The question is, how do you override the default locale value. To be honest, I don't know how to do this or if it's even possible. That would obviously be the easiest solution.

    However, if that's not possible, what you can do is create a class that extends DatePicker. Then create another class that extends DefaultCalendarView and overrides the setup method. Copy over the same method source but change the start date to Monday instead of using the start date from CalendarUtil. Then create your custom DatePicker using your custom DefaultCalendarView. It's a hack, but it should work.

提交回复
热议问题