Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Datepicker and dateformat

Hi!

I know there´s a lot of threads regarding datepicker and date format, but i haven´t found a solution to my problem yet.

I need to change the format of the datepicker to dd-MM-yyyy. The datepicker is not bound to a model. Here is an example:

var oDatePicker1 = new sap.ui.commons.DatePicker('date1');

oDatePicker1.setYyyymmdd("20100101");

oDatePicker1.setLocale("de");

It outputs 01.01.2010 - how to change this to 01-01-2010?

Kind regards,

Kim

Former Member
replied

var oDatePicker1 = new DatePicker('date1');

oDatePicker1._formatValue(new Date());

oDatePicker1._oFormat = sap.ui.core.format.DateFormat.getInstance(

    {pattern: "dd-MM-yyyy", strictParsing: true, calendarType: sap.ui.core.CalendarType.Gregorian});

     

dont like using internal variable/functions - wrap it as a custom control

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question