support: Customer Portal
Focused on delivering choice, investment protection and flexibility to organizations with valuable COBOL assets
 

Veryant Knowledge Base
Home > All Categories > isCOBOL General > Interfacing with Java Programs > Example of COBOL using Java classes to get date and time zone information
Question Title 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:

   iscc calendar.cbl
   iscrun CALENDAR 
For instance, running the program with this command:
   iscrun CALENDAR 20230215
returns this information:
   Getting information for 20230215
   ERA: 1
   YEAR: 2023
   MONTH: 1
   WEEK_OF_YEAR: 7
   WEEK_OF_MONTH: 3
   DATE: 15
   DAY_OF_MONTH: 15
   DAY_OF_YEAR: 46
   DAY_OF_WEEK: 4
   DAY_OF_WEEK_IN_MONTH: 3

   Getting information for current time
   AM_PM: 0
   HOUR: 9
   HOUR_OF_DAY: 9
   MINUTE: 40
   SECOND: 15
   MILLISECOND: 549
   ZONE_OFFSET: -8
   DST_OFFSET: 0
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:

   iscc day-of-week.cbl
   iscrun DAY_OF_WEEK 
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.

Authored by: Veryant Support This question has been viewed 12662 times so far.
Click Here to View all the questions in Interfacing with Java Programs category.
File Attachments File Attachments
How helpful was this article to you?
User Comments User Comments Add Comment
There are no user comments for this question. Be the first to post a comment. Click Here
Related Questions Related Questions
  1. 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?
  2. How to create and write an excel spreadsheet playing with different attributes like font, color, format, highlight, etc?.
Article Information Additional Information
Article Number: 119
Created: 2010-01-29 4:00 PM
Rating: 1 Star
 
Article Options Article Options
Print Question Print this Question
Email Question Email Question to Friend
Export to Adobe PDF Export to PDF File
Export to MS Word Export to MS Word
Bookmark Article
Subscribe to Article Subscribe to Article
 
Search Knowledge Base Search Knowledge Base



 
 

© Veryant - All Rights Reserved
Veryant and isCOBOL are trademarks or registered marks of Veryant in the United States and other countries. All other marks are the property of their respective owners.