Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Date and Time Processing →  Time Stamps →  Time Stamps in Packed Numbers 

System Class for Time Stamps in Packed Numbers

The class CL_ABAP_TSTMP is used to calculate and convert time stamps in packed numbers. Important methods include:

  • The method ADD or SUBTRACTSECS adds or subtracts seconds from time stamps.
  • The method TD_SUBTRACT calculates the difference between two time stamps.
  • The method MOVE converts the long form of time stamps to the short form, and back, avoiding unwanted rounding effects.
  • The method NORMALIZE normalizes time stamps. Invalid time stamps are converted into valid time stamps.
  • The methods UTCLONG2TSTMP, UTCLONG2TSTMP_SHORT, and TSTMP2UTCLONG convert the content of time stamp fields to representation in packed numbers and back.

Other versions: 7.31 | 7.40 | 7.54


Note

Conversions between time stamp fields and packed numbers are necessary for work with time stamp fields in new programs, but existing repositories or interfaces need to be accessed at the same time.


Example

Creation of a one hour earlier time stamp by subtracting 3600 seconds.

GET TIME STAMP FIELD DATA(ts1). 

DATA(ts2) = cl_abap_tstmp=>subtractsecs( tstmp = ts1 
                                       secs  = 3600 ). 

cl_demo_output=>display( |{ ts1 TIMESTAMP = ISO 
                       }\n{ ts2 TIMESTAMP = ISO }| ).

Example

Converts a time stamp field to time stamps in packed numbers. In formatting using string templates, the formatting option TIMESTAMP must be specified for the packed numbers to define a representation as time stamps.

DATA(ts) = utclong_current( ). 

cl_demo_output=>display( 
  |{ ts }\n{ 
     cl_abap_tstmp=>utclong2tstmp( ts ) TIMESTAMP = ISO }\n{ 
     cl_abap_tstmp=>utclong2tstmp_short( ts ) TIMESTAMP = ISO }| ).