简体   繁体   中英

Format date in Vaadin date picker

I'm using Vaadin Date picker 3.3.0

In Java, I set locale as the below code. datePicker.setLocale(Locale.CANADA_FRENCH);

But the date format display is YYYY-MM-dd.

How to format it to: YYYY/MM/dd?? Thank you!

The only way right now to influence the date format of the date picker by using the Java API is to use the locale (like you do).

There is a feature request for setting a date format manually (like datePicker.setDateFormat("YYYY/MM/dd"); ), maybe you want to give a thumb up on that feature request so that they will implement this soon: https://github.com/vaadin/vaadin-date-picker-flow/issues/156

Also in the comments of that feature request, there is described an alternative approach on how to set a date format manually by not using the Java API, but using JavaScript. Maybe you want to give it a try: https://github.com/vaadin/vaadin-date-picker-flow/issues/156#issuecomment-603904954

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM