Unix Timestamp
Unix Timestamp, also known as Epoch Time, is a date format.
This format represents the milliseconds elapsed since January 1, 1970 UTC.
Example date format: 1717635600024
The conversion of this date is 06.06.2024 01:00:00.024
.
Converting ABAP Date Format to Unix Timestamp
data: lv_date type datum value '20240606',
lv_time type uzeit value '095432',
lv_millisecond type num03 value '111',
lv_unix_timestamp type string.
cl_pco_utility=>convert_abap_timestamp_to_java(
exporting iv_date = lv_date
iv_time = lv_time
iv_msec = lv_millisecond
importing ev_timestamp = lv_unix_timestamp ).
write : 'Unix Timestamp: ' , lv_unix_timestamp.
Output:Unix Timestamp: 1717667672111
Converting Unix Timestamp Format to ABAP Date
data: lv_date type datum,
lv_time type uzeit,
lv_millisecond type num03,
lv_unix_timestamp type string value '1717667672111'.
cl_pco_utility=>convert_java_timestamp_to_abap(
exporting
iv_timestamp = lv_unix_timestamp
importing
ev_date = lv_date
ev_time = lv_time
ev_msec = lv_millisecond ).
write : 'Date: ', lv_date,
/ , 'Time: ', lv_time,
/ , 'Millisecond: ' , lv_millisecond.
Output:Date: 06.06.2024
Time: 09:54:32
Millisecond: 111
ISO 8601 Date Format
ISO 8601 is an international standard for the representation of dates and times.
Example date format: 2024-06-06T14:30:00
Converting ISO 8601 Date Format to ABAP Date Format
data: lv_date type datum,
lv_time type uzeit,
lv_iso_date_time type string value '2024-06-06T14:30:00'.
cl_gdt_conversion=>date_time_inbound(
exporting
im_value = lv_iso_date_time
importing
ex_date = lv_date
ex_time = lv_time ).
write : 'Date: ', lv_date,
/ , 'Time: ', lv_time.
Output:Date: 06.06.2024
Time: 14:30:00
Converting ABAP Date Format to ISO 8601 Date Format
data: lv_date type datum value '20240606',
lv_time type uzeit value '102132',
lv_iso_date_time type string.
cl_gdt_conversion=>date_time_outbound(
exporting
im_date = lv_date
im_time = lv_time
importing
ex_value = lv_iso_date_time ).
write : 'ISO 8601: ', lv_iso_date_time.
Output:ISO 8601: 2024-06-06T10:21:32Z