ABAP 获取JAVA时间戳及JAVA时间戳转换ABAP 日期时间

1.日期时间转换成JAVA时间戳
FUNCTION zfm_get_java_timestamp.
*“----------------------------------------------------------------------
"“本地接口:
*” IMPORTING
*” VALUE(IV_DATUM) TYPE DATUM OPTIONAL
*" VALUE(IV_UZEIT) TYPE UZEIT OPTIONAL
*" EXPORTING
*" VALUE(EV_TIMESTAMP) TYPE STRING
*"----------------------------------------------------------------------

"SAP时间转换成Unix时间戳 cl_pco_utility=>convert_abap_timestamp_to_java
cl_pco_utility=>convert_abap_timestamp_to_java(
EXPORTING
iv_date = iv_datum "sy-datum
iv_time = iv_uzeit "sy-uzeit
IMPORTING
ev_timestamp = ev_timestamp ).
ev_timestamp = ev_timestamp(10) - 8 * 60 * 60.

ENDFUNCTION.

2.JAVA时间戳解析
FUNCTION zfm_java_timestamp_to_sap.
*“----------------------------------------------------------------------
"“本地接口:
*” IMPORTING
*” VALUE(IV_TIMESTAMP) TYPE STRING OPTIONAL
*" EXPORTING
*" VALUE(EV_DATUM) TYPE DATUM
*" VALUE(EV_UZEIT) TYPE UZEIT
*"----------------------------------------------------------------------
"Unix时间戳转换成SAP时间 cl_pco_utility=>convert_java_timestamp_to_abap
iv_timestamp = ( iv_timestamp + 8 * 60 * 60 ) * 1000 .
cl_pco_utility=>convert_java_timestamp_to_abap(
EXPORTING
iv_timestamp = CONV #( iv_timestamp )
"iv_timestamp = CONV #( lv_timestamp )
IMPORTING
ev_date = ev_datum
ev_time = ev_uzeit ).

ENDFUNCTION.

你可能感兴趣的:(ABAP,SAP,abap,SAP)