Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

sap.m.DateTimeInput gives the wrong month

$
0
0

Hi All,

 

I try to create a view with two Date field of the type sap.m.DateTimeInput. The first datefield is should be the current date and the second date field is the general SAP HR enddate 31-12-9999.

 

When I test my view the day en year is correct, but the month is always Januari. What is wrong in my source?




var today = new Date();

  var dd = today.getDate();

  var mm = today.getMonth(); // January is 0!

 

  var yyyy = today.getFullYear();

  if (dd < 10) {

  dd = '0' + dd

  }

  if (mm < 10) {

  mm = '0' + mm

  }

  var today = yyyy + '-' + mm + '-' + dd + 'T00:00:00';

 

  this.countrySelect = new sap.m.Select("countrySelectId");

  this.countrySelectItems = new sap.ui.core.Item("countrySelectItemId", {

       key : "{Land1}",

       text : "{Landx50}"

  });

 

  this.addressTypeSelect = new sap.m.Select("addressTypeSelectId");

  this.addressTypeSelectItems = new sap.ui.core.Item({

       key : "{Subtype}",

       text : "{SubtypeText}"

  });

 

  var addressTypeSimpleForm = new sap.ui.layout.form.SimpleForm({

  minWidth : 1024,

  maxContainerCols : 2,

  editable : true,

  content : [      new sap.ui.core.Title({

                           text : "Adrestype"

                      }),

                       new sap.m.Label({

                           text : oBundle.getText("ADDRESSTYPE"),

                           required : true

                      }), this.addressTypeSelect, ]

                 });

 

  var addressPeriodSimpleForm = new sap.ui.layout.form.SimpleForm({

 

  minWidth : 1024,

  maxContainerCols : 2,

  editable : true,

  content : [  new sap.ui.core.Title({ text : "Periode"}),

                    new sap.m.Label({text : oBundle.getText("BEGDA")}),

                    new sap.m.DateTimeInput({

                                enabled : true,

                                value : today,

                                valueFormat : "yyyy-mm-ddThh:mm:ss",

                                displayFormat : "dd MMMM, yyyy",

                     }),

                    new sap.m.Label({text : oBundle.getText("ENDDA"}),

                    new sap.m.DateTimeInput({

                                enabled : true,

                                value : "9999-12-31T00:00:00",

                                valueFormat : "yyyy-mm-ddThh:mm:ss",

                                displayFormat : "dd MMMM, yyyy",

                      }),

               ]

  });

 

Kind Regards,

Richard


Viewing all articles
Browse latest Browse all 6178

Trending Articles