简体   繁体   English

sapui5中的时间是Nan值

[英]Time in sapui5 is Nan Value

I am using SAPUi5 for Time.The time fValue is PT12H50M00S.When showing on dropdownbox it is showing Nan,result is shown as NaN:NaN:NaN PM,How to convert this to values. 我正在使用SAPUi5作为时间。时间fValue是PT12H50M00S。在下拉框上显示时,它显示Nan,结果显示为NaN:NaN:NaN PM,如何将其转换为值。

var oItemTemplate2 = new sap.ui.core.ListItem({
  text: {
    path: "SlotTi",
    formatter: function(fValue) {
      jQuery.sap.require("sap.ui.core.format.DateFormat");
      var oTimeFormat = sap.ui.core.format.DateFormat.getTimeInstance({
        pattern: "KK:mm:ss a"
      });
      if (fValue != undefined || fValue != null) {
        fValue = fValue.toString();
      }
      return oTimeFormat.format(new Date(fValue));
    }
  }
});

I am able to resolve that issue using below code, But with this the dropdown is showing the same time for every value. 我可以使用下面的代码解决该问题,但与此同时,下拉菜单显示的是每个值的相同时间。

SlotTi: "PT08H00M00S" SlotTi: "PT08H10M00S" SlotTi:“ PT08H00M00S” SlotTi:“ PT08H10M00S”

The value shown is 3:00:00 显示的值为3:00:00

What is missing to show the values. 缺少什么来显示值。

   var oItemTemplate2 = new sap.ui.core.ListItem(
          {
            text :
            {
              path:"SlotTi",
              formatter : function(fValue)
              {
                jQuery.sap.require("sap.ui.core.format.DateFormat");
                var oTimeFormat = sap.ui.core.format.DateFormat.getTimeInstance(
                    {
                      pattern: "KK:mm:ss a"
                    });
                if( fValue != undefined || fValue != null){
                  fValue = Date(oTimeFormat.parse(fValue));
                }
                return oTimeFormat.format(new Date(fValue));
              }
            }
          });
      oItemTemplate2.bindProperty("enabled", "enabled");
      dropbox.bindItems("/d/results", oItemTemplate2);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM