cancel
Showing results for 
Search instead for 
Did you mean: 

DateFormat depends by the user profile

0 Kudos
587

Hey Experts!

I have a problem with my date formatter on my View. My date should be formatted according to the user profile. I get my date time from a database by a oDataModel like: Fri Aug 26 2016 02:00:00 GMT+0200 (W. Europe Daylight Time)

and as i mentioned i want to fomat it accoring to the user profile with this code snipped:

// For date/time values require the DateFormat class

jQuery.sap.require('sap.ui.core.format.DateFormat')

// Instantiate the date, time, datetime classes, without a parameter or based on a certain style (either 'short', 'medium' or 'long')

var oDateFormat = sap.ui.core.format.DateFormat.getDateInstance();

// Use any of the variables above to format a date or time value (using JavaScript "Date" objects):

oDateFormat .format(new Date());

The problem is my oData date is a string and not a js-object which i need to format my oData model output correctly.

Have you an idea to fix this problem? fyi i want to implement this datefommater into a ColumListItem control which used as a template to bind my models to a table below this text you will see how i do it at the moment:

Here is how my template looks like with a working but static date time formatter 1# (i want replace this static fomatter with the new method above):

1# My static formatter

2# My template for binding

Best Regards,
Danilo

View Entire Topic
venkatachala_ck
Active Participant
0 Kudos

Hi Danilo,

check out this link.

JS Bin - Collaborative JavaScript Debugging

Thanks

Venkat

0 Kudos

Hey Venkat,

your solution shows me only predefined variables but i need to know how i can commit my fetched oData Model into the frmt2.format(new Data(sDate))  sDate ::= fetched oDataModel