A date or time can be formatted in a culturally appropriate way by using LOCALE functions. In the example below locale object (type *LOCALE) EN_US must be created in library QSYSLOCALE before running the COBOL program. For more information about how to create a locale object, refer to Creating Locales on the iSeries.
The LOCALE functions take an alphanumeric item (a character string) in the format of a date, for the LOCALE-DATE intrinsic function, or in the format of a time, for the LOCALE-TIME intrinsic function and return another alphanumeric item with the date or time formatted in a culturally appropriate way.
The argument for LOCALE-DATE must be an 8-byte character string in a date format specified by the CURRENT-DATE intrinsic function. The argument for LOCALE-TIME must be an 13-byte character string in a time format specified by the CURRENT-DATE intrinsic function, positions 9 through 21.
For example:
SPECIAL-NAMES. LOCALE "EN_US" IN LIBRARY "QSYSLOCALE" IS usa.
·
·
·
DISPLAY "Date is:" FUNCTION LOCALE-DATE("19970908" usa). DISPLAY "Time is:" FUNCTION LOCALE-TIME("06345200+0000" usa).
would display:
Date is: 08/09/1997 Time is: 06:34:52
In the above example, argument-1 for the LOCALE-DATE function, 19970908, represents the 4-digit year, followed by the month, followed by the day of the month. Argument-1 for the LOCALE-TIME function, 06345200+0000, represents the following:
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.