Skip to Content

SAPUI5 Formatting UTC DateTime String in Text

Hello everyone,


I've been struggling with this for hours now, and I hope someone could help me.

I have a JsonModel bound to my table, that has a String Property with the following format:

yyyy-MM-ddTHH:mm:ss

I wanted to format this date on my Text control like 'yyy-MM-dd'. However, my text is always emtpy and I receive the error message "The given date instance isn't valid"

My string looks like this:

2017-07-11T00:00:00+02:00

And my text control like this:

 <Text text=" { 
                path:'Produced', 
                type:'sap.ui.model.type.Date', 
                formatOptions: { 
                  source : { 
                    pattern: 'yyyy-MM-ddTHH:mm:ss' 
                  },
                  pattern: 'yyyy-MM-dd'
                } 
              }"/>

The binding is correct, because if I remove the formatoptions the string is displayed.

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Feb 14 at 04:31 PM

    Your pattern is incorrect, it should be

    pattern: 'yyyy-MM-ddTHH:mm:ss X'

    Regards,

    Jamie

    Add comment
    10|10000 characters needed characters exceeded