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 a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Feb 14, 2018 at 04:31 PM

    Your pattern is incorrect, it should be

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

    Regards,

    Jamie

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.