cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Date Field Conversion In SAP UI5

former_member195777
Participant
0 Kudos

HI All,

I am Getting the Date field as a string(20171004) format, i need show as a Date Format

( 2017 October 04 ) pls help dateissue.jpg

Accepted Solutions (1)

Accepted Solutions (1)

ericci
Active Contributor
0 Kudos

Well, what you can do is to

var match = /([0-9]{4})([0-9]{2})([0-9]{2})/gi.exec("20171004");
var matchedDate = new Date(match[1], match[2]-1, match[3]);
var dateFormat = sap.ui.core.format.DateFormat.getDateInstance({pattern : "YYYY/MM/dd" }); 
var dateFormatted = dateFormat.format(matchedDate);

Now what you need to do is just to edit the pattern value in which format you want to print it to the user.

former_member195777
Participant
0 Kudos

Thanks Ricci,

its Working .

ericci
Active Contributor

You're welcome! Don't forget to also up vote the answer 😉

former_member195777
Participant
0 Kudos

OK Ricci Thanks

Answers (0)