0

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);
Ron
  • 1,450
  • 15
  • 27
  • I know it is an old question, but I am trying to find the answer to it. Did you find a way to do it other than changing to a different Locale ? – c0der Nov 22 '15 at 18:17

1 Answers1

0

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.

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);
Ron
  • 1,450
  • 15
  • 27
  • 1
    `setFirstDayOfWeek` is void, it can't be applied to `setCalendar(Calendar c)`, you need to store `dateChooser.getCalendar()` into a `Calendar` object, then use `setFirstDayOfWeek` on that object, then pass it as parameter to the `setCalendar` method. – BackSlash Sep 30 '13 at 13:27
  • Ok, I do like this and it doesn't change the first day of week, is still Sunday. JDateChooser dateChooser = new JDateChooser(new Date()); Calendar calendar = new GregorianCalendar(); calendar.setFirstDayOfWeek(Calendar.MONDAY); dateChooser.setCalendar(calendar); – c georgian Sep 30 '13 at 17:11
  • Ok, seems that the first day of the week is changed to Monday if we set a locale for a country for which the week first day is Monday. Locale locale = new Locale("da", "DK"); JDateChooser dateChooser = new JDateChooser(new Date()); dateChooser.setLocale(locale); – c georgian Oct 02 '13 at 16:11
  • Still I would like to find if possible a way to change only the first day of week. – c georgian Oct 02 '13 at 16:24
  • @BackSlash You are correct, I've modified my answer to reflect your comments – Ron Oct 05 '13 at 10:58