2016-04-08 5 views
0

モデルに書き戻すためにいくつかの日付をハードコードしています。モデルを作成するときの日付の書式

など。

oEntry.StartDate = "2016-03-28T00:00:00"; 

これは、上の無効な日付のエラーを投げている:

oModel.create("/CalendarSet", oEntry, { 
    success : success, 
    error : error 
}); 

日付の正しい形式は何ですか?

+0

は、そのURLを見てみましょう:http://scn.sap.com/thread/3423205 – inetphantom

答えて

1

JavascriptのDate要素を使用できます。

oEntry = { 
    StartDate: new Date(year, month, day, hours, minutes, seconds, milliseconds) 
}; 

oModel.create("/CalendarSet", oEntry, { 
    success : success, 
    error : error 
}); 

出典:MDN

あなたはURLでSPATHのためにそれを必要とする場合は、日時文字列を取得するには、次のことができます。

getTimestamp: function getTimestamp(oDate){ //TODO: JsDoc 
     this.oLogger.info("Enterd function Timestamp(oDate)"); 
     return sap.ui.core.format.DateFormat.getDateTimeInstance({pattern : "yyyy-MM-ddTKK:mm:ss"}).format(oDate || new Date()); 
    }, 
+0

代わりにMDNを使用してください。 – hirse

+1

はい、ありがとうございます。理由はhttp://meta.stackoverflow.com/q/280478/1469028を参照してください。 – hirse

-1

これは何が必要です:

oEntry = {}; 
oEntry.StartDate = new Date(); // assuming "StartDate" is corr. fieldname in your service 
           // also assuming its the only key in your entity 
           // and its type DateTime 
oModel.create("/CalendarSet", oEntry, { 
    success : success, 
    error : error 
}); 
関連する問題