cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

UI5 UTC Date mapping problem

Former Member
0 Kudos
3,926

Hi!

I have a button on my form. When I press the button, a new datepicker appears with a default value of 31.12.9999 (31st Dec 9999).

My DatePicker:

new sap.ui.commons.DatePicker({

   value: {

        path: "oDataModel>/Feevalidto",
        type: new sap.ui.model.type.Date({

             pattern: "dd.MM.yyyy",
             UTC: true, //I need this, because without this, when I changed the value of the datePicker, saved data using oData WebService then the saved date was 1 day less than what I had entered.
             strictParsing: true
        })

   },
   change: function () {

        //stuff
   }

});


I am trying to map a default value using:


dataModel = {

   Feevalidto: new Date("9999/12/31")
};

Unfortunately when I press the button the date picker has the value of 30.12.9999.

NOTE:

When I console-d the following:

console.log(new Date("9999/12/31"));

Then I got: Fri Dec 31 9999 00:00:00 GMT+0200 (FLE Standard Time)

Can anyone explain why is this happening and how can I get it to work?

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member611303
Participant
0 Kudos

<DatePicker value="{path: 'fromDate', type: 'sap.ui.model.type.Date', formatOptions: {pattern: 'yyyy/MM/dd', strictParsing: true , UTC: true}}"></DatePicker>

former_member662960
Participant
0 Kudos

Is there a way to set the UTC value dynamically? Like taking it from a model or setting it programatically from the controller?

former_member611303
Participant
0 Kudos

hey luisa92,

Please check the below code and use current date as a UTC date or use Formatter for define UTC

  1. UTCMonth
  2. UTCDate
  3. UTCFullYear

<DatePicker value="{path: 'fromDate', type: 'sap.ui.model.type.Date', formatOptions: {pattern: 'yyyy/MM/dd', strictParsing: true , UTC: true}}"></DatePicker>

Regard

Jai Sharma

vijay_kumar49
Active Contributor
0 Kudos

Please refer this example code.it should be useful. refer this JS Bin - Collaborative JavaScript Debugging


Kindly let me know if you need any more information

Former Member
0 Kudos

Hi, Vijay!

Your code describes a simple DatePicker and a button which gets the value of the date picker. I don't think you understood my question.

My problem is that if I set the "UTC: true" then any value I bind to my model property "Feevalidto" will be changed by 1 day. So if the value bound to my property is new Date("9999/12/31") then the output will be "30.12.9999".

Hopefully you understand my problem a bit more clearly now.