cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to set datetime format for third party datetime picker

Former Member
0 Kudos

Hi,

          In our sap ui5 application we used third party date time picker plugin in one pop-up  for insert update operations. Client told us to do not use the sap.m date time picker so we don't have any other choice that's why we have chosen one third party date time picker plugin .While inserting the date it was working fine but while retrieving the date time value from service to pop-up for update functionality the format has been changed completely.So i want to set the format for that date time picker i have tried the below code but does not worked fine will any one please give some suggestion....

var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "MM/d/y H:mm:ss A"});

var formattedStartDate = oDateFormat.format((startDate));

startDate.setValue(formattedStartDate);

Thanks in Advance for your help.

Regards

Selva

Accepted Solutions (1)

Accepted Solutions (1)

naveenraj_a
Active Participant
0 Kudos

Hi Selva,

For setting the Date to the UI, make sure your entity is having the date field in Edm.DateTime type and your model is having date field in PT format, for eg. PT14H01M00S.

For more clarity, pls see this link

http://scn.sap.com/community/developer-center/front-end/blog/2013/04/28/working-with-odata-dates

Also let us know if you are getting any error in your browser console while setting the date to UI control.

Thanks

Naveenraj

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Gopal,

See the example below:

new sap.ui.commons.DatePicker("date",{

  width: "10em",

  value: {

  path: "myModel>/dateValue",

//the format information

      type: new sap.ui.model.type.Date({pattern: "DD/MM/YYY" , source :{pattern: "MM/d/y H:mm:ss A"}

Regards,

Ashvin