Eng.Fouad Eng.Fouad - 2 years ago 128
Java Question

Set the first day of the week in JavaFX's DatePicker

Is it possible to change the first day of week on JavaFX's DatePicker when applying Arabic locale? I need to change it from Saturday to Sunday.

enter image description here

Answer Source

I was able to change the first date of the week by injecting the following class within my application:

package sun.util.resources.ar;

import sun.util.resources.LocaleNamesBundle;

public final class CalendarData_ar_SA extends LocaleNamesBundle
    protected final Object[][] getContents()
        return new Object[][] { { "firstDayOfWeek", "1" }, { "minimalDaysInFirstWeek", "1" } };

enter image description here

Do not forget to change the default locale:

public static final Locale SAUDI_AR_LOCALE = new Locale.Builder().setLanguageTag("ar-SA-u-nu-arab").build(); // nu is for numbers

// ....

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download