avatar image
Former Member

SAPUI5 date time issue

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    May 23, 2017 at 05:57 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • May 24, 2017 at 08:58 AM

    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>
    Add comment
    10|10000 characters needed characters exceeded

  • Jun 08, 2017 at 12:12 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

Skip to Content