is possible to set a Locale for com.google.gwt.user.datepicker.client.DatePicker? I need to show the days and the weeks in italian style.
thanks
is possible to set a Locale for com.google.gwt.user.datepicker.client.DatePicker? I need to show the days and the weeks in italian style.
thanks
Here is a datepicker widget for gwt that handle locale.
The demo for italian locale.
I hope it helps you.
The javadoc for DatePicker
has an example that should get you started - you just have to format the date using DateTimeFormat
in a 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 your default locale - if you want to change it to something else, there'a whole section on how you can do it in the GWT docs.
Locales in GWT are set global.
You can set the local e.g. in a meta tag in your html file:
<html><head><meta name="gwt:property" content="locale=it">...
and you have to add the locale to the modulefile *.gwt.xml:
<extend-property name="locale" values="it"/>
The properties are defined here:
com.google.gwt.i18n.client.constants.DateTimeConstantsImpl_xx.properties
For more, read the documentation.