Skip to Content
0

SAPUI5 Formatting UTC DateTime String in Text

Feb 14 at 02:02 PM

124

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Jamie Cawley
Feb 14 at 04:31 PM
1

Your pattern is incorrect, it should be

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

Regards,

Jamie

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hello Jamie,

thank you very much! That's it!

Regards,

Chris

0