GWT DatePicker Locale

can I set the locale for com.google.gwt.user.datepicker.client.DatePicker? I need to show days and weeks in Italian style.

+4
source share
3 answers

Here is the datepicker widget for gwt that handle locale .

demo for the italian locale.

Hope this helps you.

+3
source

There is an example in javadoc for DatePicker that should launch you - you just need to format the date using the DateTimeFormat in the ValueChangeHandler assigned to your DatePicker :

 public class DatePickerExample implements EntryPoint { public void onModuleLoad() { // Create a date picker DatePicker datePicker = new DatePicker(); final Label text = new Label(); // Set the value in the text box when the user selects a date datePicker.addValueChangeHandler(new ValueChangeHandler() { public void onValueChange(ValueChangeEvent event) { Date date = event.getValue(); String dateString = DateTimeFormat.getMediumDateFormat().format(date); text.setText(dateString); } }); // Set the default value datePicker.setValue(new Date(), true); // Add the widgets to the page RootPanel.get().add(text); RootPanel.get().add(datePicker); } } 

This will format the date in the default locale - if you want to change it to something else, the entire section on how you can do this in GWT docs.

0
source

Locales in GWT are set global.

You can set local, for example. in the meta tag in your html file:

 <html><head><meta name="gwt:property" content="locale=it">... 

and you should add the locale to the * .gwt.xml module file:

 <extend-property name="locale" values="it"/> 

Properties are defined here:

com.google.gwt.i18n.client.constants.DateTimeConstantsImpl_xx.properties

Read the documentation for more details.

0
source

Source: https://habr.com/ru/post/1302046/


All Articles