COBOL use timestamp

Display timestamp in COBOL.


Program Sample:


       IDENTIFICATION DIVISION.
       PROGRAM-ID. TESTTIMESTAMP.
       ENVIRONMENT DIVISION.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
        01 WS-CURRENT-DATE-DATA.
           05  WS-CURRENT-DATE.
               10  WS-CURRENT-YEAR         PIC 9(04).
               10  WS-CURRENT-MONTH        PIC 9(02).
               10  WS-CURRENT-DAY          PIC 9(02).
           05  WS-CURRENT-TIME.
               10  WS-CURRENT-HOURS        PIC 9(02).
               10  WS-CURRENT-MINUTE       PIC 9(02).
               10  WS-CURRENT-SECOND       PIC 9(02).
               10  WS-CURRENT-MILLISECONDS PIC 9(02).
               10  WS-GMT-SIGN             PIC X(01).
               10  WS-GMT-TIME             PIC X(04).
*     *(NOTE:  WS-GMT-SIGN AND WS-GMT-TIME IS GREENWICH MEAN TIME OFFSET)

       PROCEDURE DIVISION.
           MOVE FUNCTION CURRENT-DATE to WS-CURRENT-DATE-DATA.
           DISPLAY WS-CURRENT-DATE-DATA.

           STOP RUN.


Execution Result:

2015070620042585-0700


means: 2015-07-06 20:04:25.85 (GMT-7)

The milliseconds fields can be 00-99, so its minimum unit is 10 milliseconds.



Refer to:

http://documentation.microfocus.com/help/index.jsp?topic=%2Fcom.microfocus.eclipse.infocenter.studee60win%2FHRLHLHPDF709.html


你可能感兴趣的:(COBOL)