2017-11-17 7 views
0

日付を抽出してラベルに表示する日付ピッカーがあります。現在、日付はMM/DD/YYYYの形式で表示されていますが、MMM dd、yyyy(2017年11月17日)の形式で入力してください。以下のコードです:SAPUI5の後に日付ピッカーからピッキングした日付のフォーマットを変更する

screenDate=view.byId("screeningDate").getValue(); 
var date = view.byId("__date"); 
date.setText(screenDate); 

XML:FYI

<HBox alignItems="Center" renderType="Bare"> 
        <Label text="Date of Screening" width="50%"/> 
        <DatePicker class="sapUiLargeMarginBegin" width="50%" id="screeningDate"/> 
       </HBox> 

答えて

1

ここにあなたの既存のコードを持つソリューションです:

は、
screenDate=view.byId("screeningDate").getValue(); 
var date = view.byId("__date"); 
// Make date object out of screenDate 
var dateObject = new Date(screenDate); 
// SAPUI5 date formatter 
var dateFormat = sap.ui.core.format.DateFormat.getDateInstance({pattern : "MMM dd,YYYY" }); 
// Format the date 
var dateFormatted = dateFormat.format(dateObject); 
date.setText(dateFormatted); 
0

、ビューコントロールを取得し、それは良くないでプロパティを更新することによって。あなたがモデルを持っているなら、それはいいでしょう。 Naveenの答えに加えて

あなたの問題のため

ソリューションは以下の通りです、

<Label text="{ 
      path: '/date', 
      type: 'sap.ui.model.type.Date', 
      formatOptions: { 
       style: 'medium', 
       pattern: 'MMM dd, yyyy' 
      }}"/> 
<DatePicker dateValue="{/date}"/> 

そして、私は以下のようにJSONModelを持つコントローラで、

onInit : function() { 
    this.model = new JSONModel({ 
     date : new Date(0) 
    }); 
    this.getView().setModel(this.model); 
} 
関連する問題