datePicker with monday as 1-st day of the week

Hi,
I not found in properties of Studio something for first day of the week for this component so was necessary to rewrite to change from Sunday to Monday the first day of the week, my code may be help someone:

    @ViewComponent
    private TypedDatePicker<LocalDate> germEvalDateField;
    @ViewComponent
    private TypedDatePicker<LocalDate> germStartDateField;

    @Subscribe
    public void onInit(final InitEvent event) {
        final Locale locale = currentAuthentication.getLocale();
        // check if user choose Română for display language
        if (locale.getDisplayLanguage().equals("română")) {
            // set the date piker in Romanian
            germStartDateField.setI18n(romanianI18nDatePicker());
            germEvalDateField.setI18n(romanianI18nDatePicker());
        }
        // call some methods
        initManualTooltip();
        checkFields();
    }

// more code lines

  // method for create date picker in Romanian language
    protected DatePicker.DatePickerI18n romanianI18nDatePicker() {
        DatePicker.DatePickerI18n romanianI18n = new DatePicker.DatePickerI18n();

        // set Monday as first day of the week
        romanianI18n.setFirstDayOfWeek(1);
        // set the list with the months
        romanianI18n.setMonthNames(
                List.of("Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie",
                        "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie")
        );
        // set the list with long name of week days
        romanianI18n.setWeekdays(
                List.of("Duminică", "Luni", "Marți", "Miercuri", "Joi", "Vineri", "Sâmbătă")
        );
        // set the list with short name of week days
        romanianI18n.setWeekdaysShort(
                List.of("dum.", "lun.", "mar.", "mie.", "joi", "vin.", "sâm.")
        );
        // translate Today
        romanianI18n.setToday("Astăzi");
        // translate Cancel
        romanianI18n.setCancel("Anulare");
        // set date format
        romanianI18n.setDateFormat("dd/MM/yyyy");

        // return the date picker for Romanian language
        return romanianI18n;
    } 

Exist another easy solution for this?

Hi!

The typedDatePicker component (like typedDateTimePicker) calculates the first day of the week based on the user’s locale (see io.jmix.flowui.component.DateInternationalizationHelper#getFirstDayOfWeek).

The calculation uses the locale’s Calendar definition of the first day of the week:
image

As far as I can see, for ro [Română] locale, the first day of the week is set to Sunday, and for ro-RO [Romanian (Romania)] locale, the first day of the week is set to Monday.

I think you need to change the locale of your application to ro-RO.

You can change the name displayed in the locale drop-down from Romanian (Romania) to Română using the following key:

localeDisplayName.ro_RO = Română

Best regards,
Dmitriy

1 Like

Hi Dmitriy and thank you,
With the language set for application to ro-RO work. I seen at first look take it the translated messages, labels also integerFormat numberDecimalSeparator and numberGroupingSeparator defined in messages-ro.properties.
Only if I set again integerFormat numberDecimalSeparator and numberGroupingSeparator for ro-RO created a new file messages-ro-RO.properties but translated messages and labels is taken also from messages-ro.properties.