Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Problem in datepicker with a different format #72

Closed
jcgueriaud opened this issue May 7, 2018 · 5 comments
Closed

Problem in datepicker with a different format #72

jcgueriaud opened this issue May 7, 2018 · 5 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jcgueriaud
Copy link

jcgueriaud commented May 7, 2018

I set a date format (in french it's DD/MM/YYYY instead MM/DD/YYYY) for the datepicker (from vaadin flow version beta9).
If you choose france locale and set a localeDate (now()) then the display date is 5/7/2018 (instead of 07/05/2018).
If you use Edge (I don't have problems with Firefox or chrome), and select 31/05/2018 (31st May) then it's interpreted as Month = 31 and day = 05 (so the selected date is in 2020).

Here an example:

@BodySize(height = "100vh", width = "100vw")
@HtmlImport("styles/shared-styles.html")
@Route("datePicker")
@Theme(Lumo.class)
public class DatePickerView extends VerticalLayout {


private DatePicker datePicker;


public DatePickerView() {
    datePicker = new DatePicker();
    datePicker.setLocale(Locale.FRANCE);
    datePicker.setValue(LocalDate.now());


    if (datePicker.getLocale().equals(Locale.FRANCE)) {
        DatePicker.DatePickerI18n datePickerI18n = new DatePicker.DatePickerI18n();
        datePickerI18n.setWeek("Semaine");
        datePickerI18n.setCalendar("Calendrier");
        datePickerI18n.setClear("Vider");
        datePickerI18n.setToday("Aujourd'hui");
        datePickerI18n.setCancel("Annuler");
        datePickerI18n.setWeekdays(Arrays.asList("Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"));
        datePickerI18n.setWeekdaysShort(Arrays.asList("Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"));
        datePickerI18n.setMonthNames(Arrays.asList("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août",
                "Septembre", "Octobre", "Novembre", "Décembre"));
        datePicker.setI18n(datePickerI18n);
    }
    add(datePicker);
    setClassName("main-layout");
}

}
@Legioth
Copy link
Member

Legioth commented May 9, 2018

Probably related to #57

@jcgueriaud
Copy link
Author

I don't know if i need to create a new ticket but I tried with Vaadin platform beta 11 ( com/vaadin/vaadin-date-picker-flow/1.0.0.beta14/vaadin-date-picker-flow-1.0.0.beta14.jar and org/webjars/bowergithub/vaadin/vaadin-date-picker/3.0.1/vaadin-date-picker-3.0.1.jar ).

And I have the same issue If you choose france locale and set a localeDate (now()) then the display date is 5/30/2018 (instead of 30/05/2018).

The problem seems solved for edge.

@ZheSun88
Copy link
Contributor

I am doing the following way and i think i can get the correct format with vaadin-date-picker-flow beta14
image

or could you provide your code? you can open a new issue, if you are still having this problem

@caalador
Copy link
Contributor

Created a new ticket on the issue. #84

@ugurdoksan
Copy link

DatePicker dpStartDate = new DatePicker( "" );
dpStartDate.setLocale( new Locale( "tr", "TR" ) );

TR Locale working fine in Laptop browsers but not in mobile browsers.
When I choose June 2018, it gives me something like 1931 exc...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants