0

I have a table control in linked to a backend OData service. One of the column contains the value "Start time" which is coming from backend as PT01H15M32S. Is there any way that I can convert this format to the legible format? Below is how I am trying to achieve it.

oTable.addColumn(new sap.ui.table.Column({
  label: new sap.ui.commons.Label({text: "Start Time"}),
  template: new sap.ui.commons.TextView().bindProperty("text", {
    path: "STRTTIME",
    type: new sap.ui.model.type.Time({
      source: {
        __edmtype: "Edm.Time"
      },
      pattern: "HH:MM:SS"
    })
  }),
  sortProperty: "STRTTIME",
  editable: false,
}));

There is also a function formatValue for sap.ui.model.type.Time, but I am not sure how can I use it to get the correct time format.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Manpreet
  • 21
  • 1
  • 4

1 Answers1

2

By using types you don't need to call formatValue as the runtime will do this for you. However, you should use the correct type: sap.ui.model.odata.type.Time! The type you are using does not support EDM data types. Also your coding looks strange.

oTable.addColumn(new sap.ui.table.Column({
    label: new sap.ui.commons.Label({text: "Start Time"}),
    template: new sap.ui.commons.TextView({
          "text" : { 
              path : "{STRTTIME}",
              type: new sap.ui.model.odata.type.Time({
                  source : { __edmtype: "Edm.Time" }, pattern: "HH:MM:SS" })
              })
           }
    }),
    sortProperty: "STRTTIME",
    editable: false,
}));
matbtt
  • 4,230
  • 19
  • 26
  • thanks for highlighting the incorrect type. I am pretty new to this and I am not able to correctly use the type: new sap.ui.model.type.Time.formatValue. – Manpreet Mar 17 '16 at 12:28