Example of COBOL using Java classes to get date and time zone information
The attached program 'calendar.cbl' uses OOP to return information about a passed date and the current time using the java.util.GregorianCalendar and other related classes.
You can compile and run it as follows:
For instance, running the program with this command:
iscrun CALENDAR 20230215
returns this information:
Getting information for 20230215
Getting information for current time
This program was based on the attached Java example, also found here: http://java.sun.com/javase/6/docs/api/java/util/GregorianCalendar.html
The DAY_OF_WEEK in the example above is '4', which means it's a Wednesday.
Another way to get the text of the day of the week is to use java.time classes.
You can compile and run this attached sample as follows:
The output for February 15, 2023 is WEDNESDAY.
Another way to work with the date and day is using isCOBOL and intrinsic functions.
Knowledge Base Article # 336 talks about how to manipulate dates using intrinsic functions.
The sample programs installed in $ISCOBOL/sample/is-java/iscobol-uses-cobol-object shows how to use these intrinsic functions in class-id programs, creating COBOL objects that can then be used in programs using OOP, similar to how the examples in this KB article use native Java objects.
by: Veryant Support
This question has been viewed 12012 times so far.
Here to View all the questions in Interfacing with Java Programs
| User Comments
|There are no user comments for this question. Be the first to post a comment. Click Here
| Related Questions
- We plan to replace our CICS screens with Java dialogs. How will the COBOL structures be passed between the Java dialogs and the other COBOL programs?
- How to create and write an excel spreadsheet playing with different attributes like font, color, format, highlight, etc?.