Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[ABAP] Convert JavaScript Timestamp to yyyy-MM-dd’T’HH:mm:ss

DATA(lv_js_timestamp) = "/Date(1615161600000)/".

"Extract /Date(1615161600000)/ to 1615161600000
FIND REGEX '([0-9]+)' IN lv_js_timestamp IGNORING CASE SUBMATCHES DATA(js_timestamp).

cl_pco_utility=>convert_java_timestamp_to_abap( EXPORTING iv_timestamp = js_timestamp
                                                IMPORTING ev_date      = DATA(lv_date)
                                                          ev_time      = DATA(lv_time) ).
"2021-03-08T00:00:00
CONVERT DATE lv_date TIME lv_time INTO TIME STAMP DATA(timestamp) TIME ZONE 'UTC'.
rv_datetime = |{ timestamp TIMESTAMP = ISO }|.

Leave a Reply

Your email address will not be published. Required fields are marked *