/scripts/ahub.form.attachments.js
0

SAPUI5 date time issue

May 23, 2017 at 04:29 PM

492

avatar image

I am using a DateTimePicker but when sending data to the backend it subtracts 1h.

E.g. I chose 23.05.2017 17:20:27 and if I check the "Network" tab in Chrome it shows:

FinishDate=datetime%272017-05-23T16%3A20%3A00%27

So 1h less and the same is shown in the Gateway so looks like a time zone problem.

Any idea why this is happening?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Madhusudhan S May 23, 2017 at 05:57 PM
1

Hi Radek,

Please add UTC and set it to true in the declaration and check it that solves the issue.

new sap.m.DatePicker({
value : {
    path : "Date",
    type : new sap.ui.model.type.Date({
                style: "short",
                UTC: true
        })
}
})

We also faced the same issue. In desktop we see one date and tablet we see previous date. With UTC = 'X' , the issue got resolved.

Fyi : Time zone calculation logic taken care at the backend.

Regards

Madhu

Share
10 |10000 characters needed characters left characters exceeded
Akhilesh Upadhyay May 24, 2017 at 08:58 AM
0

use strictParsing and UTC in formatOptions.

<DatePicker value="{path: 'date', type: 'sap.ui.model.type.Date', formatOptions: {pattern: 'dd.MM.yyyy', strictParsing: true , UTC: true}}">
</DatePicker>
Share
10 |10000 characters needed characters left characters exceeded
Michael Lichtinger Jun 08, 2017 at 12:12 PM
0

Hi Radek,

you also could check/change the data type in ABAP Type Editor (SAP Gateway Service Builder) without changing anything in the Frontend (UI5).

1) Go to transaction SEGW (and open your relevant project)

2) Navigate to the Properties of your Entity Type and call the ABAP Type Editor from the property with the EDM Core Type "Edm.DateTime".

Note, for test purposes I added a property "Ledat" manually.

==> In this case, the Data Type is not suitable; we need the associated type "DATS".

3) Change the Associated Type

-> Mode: 2 Explicit Assignment

-> Category: D Data Element (already ok)

==> Associated Type: DATS

In my case this was working.

BR

Michael


org-datatype.png (15.5 kB)
new-datatype.png (15.3 kB)
Share
10 |10000 characters needed characters left characters exceeded
Skip to Content