在JDateChooser中设置一周的第一天 [英] Set first day of week in JDateChooser
问题描述
我需要一些帮助才能在com.toedter.calendar.JDateChooser
中将星期天的第一天从星期一设置为星期一(将SMTWTFS更改为MTWTFSS),我试图这样做没有任何结果,我使用的是JDateChooser的1.3.3版本:
I need some help to be able to set the first day of week from Sunday to Monday (change SMTWTFS to MTWTFSS) in com.toedter.calendar.JDateChooser
, I tried like this with no result, I'm using version 1.3.3 of JDateChooser:
JDateChooser dateChooser = new JDateChooser(new Date());
dateChooser.getCalendar().setFirstDayOfWeek(Calendar.MONDAY);
推荐答案
遵循正确的getter实现约定,getCalendar()可能会返回所用日历的副本.因此,您对setFirstDayOfWeek()的调用是在不是 JDateChooser日历对象的对象上.
Following the conventions of proper getter implementation, getCalendar() probably returns a copy of the calendar used. Therefore your call to setFirstDayOfWeek() is on an object that is not the calendar object of your JDateChooser.
我似乎找不到JDateChooser 1.3.3的文档,但是如果存在setCalendar(),则应该可以:
I can't seem to find the documentation for JDateChooser 1.3.3, but if setCalendar() exists, this should work:
Calendar c = dateChooser.getCalendar();
c.setFirstDayOfWeek(Calendar.MONDAY);
dateChooser.setCalendar(c);
这篇关于在JDateChooser中设置一周的第一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!