在JDateChooser中设置一周的第一天 [英] Set first day of week in JDateChooser

查看:93
本文介绍了在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆