EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
  • 1.  How to change TimeStamp format

    Posted Mon May 25, 2015 06:12 AM

     

    Hello, 

    How can  I  change  the timestamp format yyyy-MM-dd HH:mm:ss:SSSSSS to  yyyy-MM-dd-HH.mm.ss.SSSSSS in EGL program ? 

    Please help 

    package programs;// basic called program//program TStamP type BasicProgram(parm1 int, parm2 string) {}            myTimeStamp string;                function main()                                myTimeStamp = DateTimeLib.currentTimeStamp();                syslib.writeStdout("Time Stamp is :  "    +  myTimeStamp) ;                myTimeStamp = strlib.db2TimeStampFormat;                syslib.writeStdout("DB2 Time Stamp is :  "    +  myTimeStamp) ;                myTimeStamp = DateTimeLib.currentTimeStamp();                syslib.writeStdout("DB2 Time Stamp is :  "    +  myTimeStamp) ;        end        endConsole Time Stamp is :  2015-05-25 18:04:12.978000DB2 Time Stamp is :  yyyy-MM-dd-HH.mm.ss.SSSSSS  (  What I want ) DB2 Time Stamp is :  2015-05-25 18:04:13.196000
    dwkey


  • 2.  Re: How to change TimeStamp format



  • 3.  Re: How to change TimeStamp format

    Posted Tue May 26, 2015 12:14 PM

    L.H.,

     

    I just set the build descriptor named defaultTimeStampFormat to be the format you wanted (yyyy-MM-dd-HH.mm.ss.SSSSSS) and it worked.  Here are my results.

    Time Stamp is :  2015-05-26-12.04.02.048000
    DB2 Time Stamp is :  yyyy-MM-dd-HH.mm.ss.SSSSSS
    DB2 Time Stamp is :  2015-05-26-12.04.12.837000

    The "defaultTimeStampFormat" is the mask that controls the dateTimeLib.currentTimestamp.

    Is your question related to the format of the dateTimeLib.currentTimeStamp or a timestamp being read from/written to a Database and the host variable is a string or CHAR?

    take care.

    markevans


  • 4.  Re: How to change TimeStamp format

    Posted Wed June 17, 2015 08:43 AM

     

    Hi Mark,

    Sorry for late response. 

    The Timestamp value is read from DB2 .  Can you help run  the following program in EGL debug mode .

    If  I run the  SQL statement "select current timestamp from sysibm.sysdummy1" in DB2 command line , I get the right format: 

    yyyy-MM-dd-HH:mm:ss:SSSSSS

     

    In RBD data perspectibe ->  sql view, you will get different result

    yyyy-MM-dd HH:mm:ss:SSS 

     

     In EGL debug mode, you also get : yyyy-MM-dd HH:mm:ss:SSS 

     

    If I want to get the format  : yyyy-MM-dd-HH:mm:ss:SSSSSS in EGL program,

    is it possible ?  

     

    package programs;// basic called program//program TStamP type BasicProgram(parm1 int, parm2 string) {}            myTimeStamp string;        myTimeStampchar26 char(26);                function main()                                try                 get singleRow with #sql{select current timestamp from sysibm.sysdummy1 }                  into myTimeStampchar26 ;                end                     syslib.writeStdout("DB2 Time Stamp is :  " + myTimeStampchar26);        myTimeStamp = DateTimeLib.currentTimeStamp();        syslib.writeStdout("DateTimeLib Time Stamp is :  " + myTimeStamp);                       end        end

     

    console value from EGL debug

    DB2 Time Stamp is              :  2015-06-17 20:09:23.531   
    DateTimeLib Time Stamp is :  2015-06-17-20.09.23.718000 

     

    dwkey


  • 5.  Re: How to change TimeStamp format

    Posted Wed June 17, 2015 09:19 AM

    L.H.,

    The Timestamp format when reading from DB2 is controlled by a JDBC property named timeStampFormat. .  Below is the text from the DB2 Knowledge Center on JDBC properties.

     

    The way to tell EGL to use it is to update the connection URL to include this property.  Normally for debug this is done using the Debug Build Descriptor and you add the property to the end of the existing URL

    (example - sqlDB = jdbc:db2://ctfmvs07.rtp.raleigh.ibm.com:8070/CTFMVS07:retrieveMessagesFromServerOnGetMessage=true;timestampFormat=1;

     

    There is also a JDBC property named timeStampPrecisionReporting that controls how many zero's you get returned in the "decimal seconds portion".

     

    The link to this help is http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.apdv.java.doc/src/tpc/imjcc_r0052038.html

     

    timestampFormat and timestampPrecisionReporting  from DB2 Knowledge Center

     

     

    timestampFormat
    Specifies the format in which the result of the ResultSet.getString or CallableStatement.getString method against a TIMESTAMP column is returned. The data type of timestampFormat is int.
    Possible values of timestampFormat are:
    Constant Integer value Format
    com.ibm.db2.jcc.DB2BaseDataSource.ISO 1 yyyy-mm-dd-hh.mm.ss.nnnnnnnnn1
    com.ibm.db2.jcc.DB2BaseDataSource.JDBC 5 yyyy-mm-dd hh:mm:ss.nnnnnnnnn1
    Note:
    1. The number of digits in the fractional part of the timestamp depends on the precision of the TIMESTAMP(p) column in the source table. If p<9, p digits are returned. If p>=9, 9 digits are returned, and the remaining digits are truncated.
    The default is com.ibm.db2.jcc.DB2BaseDataSource.JDBC.

    timestampFormat affects the format of output only.

     

    timestampPrecisionReporting
    Specifies whether trailing zeroes are truncated in the result of a Resultset.getString call for a TIMESTAMP value. The data type of this property is int. Possible values are:
    TIMESTAMP_JDBC_STANDARD (1)
    Trailing zeroes are truncated in the result of a Resultset.getString call for a TIMESTAMP value. This is the default.
    For example:
    • A TIMESTAMP value of 2009-07-19-10.12.00.000000 is truncated to 2009-07-19-10.12.00.0 after retrieval.
    • A TIMESTAMP value of 2009-12-01-11.30.00.100000 is truncated to 2009-12-01-11.30.00.1 after retrieval.
    TIMESTAMP_ZERO_PADDING (2)
    Trailing zeroes are not truncated in the result of a Resultset.getString call for a TIMESTAMP value.

     

    markevans


  • 6.  Re: How to change TimeStamp format

    Posted Wed July 08, 2015 02:15 AM

     

     

    Mark,

     

    Thanks !    By following the instructions , It's working in both RBD V9.1.1  EGL debug mode and EGL/Java runtime.

     

    The  definition  in rununit.properties is below.   TStamPX  is the sample program.   

     

    vgj.jdbc.default.database.TStamPX=jdbc:db2://localhost:50000/SAMPLE:retrieveMessagesFromServerOnGetMessage=true;timestampFormat=1;             

    L.H.Chao