2010-02-22 106 views

回答

0

DatePicker的Javadoc有應該讓你開始一個例子 - 你只需要格式化使用一個ValueChangeHandlerDateTimeFormat分配給您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); 
    } 
} 

這將在您的默認區域設置格式的日期 - 如果您想將其更改爲其他內容,請在GWT文檔中提供如何使用它的whole section

0

GWT中的語言環境設置爲全局。

您可以設置本地例如在您的HTML文件中的meta標籤:

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

,你必須將語言環境添加到modulefile * .gwt.xml:

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

的屬性定義如下:

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

有關更多信息,請閱讀文檔。