AutoSys Workload Automation

 View Only

getModTime() returns milliseconds not seconds as documented

  • 1.  getModTime() returns milliseconds not seconds as documented

    Posted Dec 31, 2014 10:45 AM

    I opened a support ticket when this published example AutoSys API code for getModTime() gave me wrong results.

     

    In  [...]/autosys/com/ca/autosys/services/request/cat2/GetGlobalsReq.html this call should print the last modified time for a global:

     


    System.out.println("Global Modification Time: " + rsp.getModTime());

     

    It showed dates in January 1970, which is the UNIX epoch, similar to seeing galaxies at the far end of a red shift.

     

    Global Modification Time: Sat Jan 17 05:24:45 EST 1970

     

    This hinted toward a date math error, but I didn't know enough Java coding to dig deeper.  But I tried a few things and found this (simplified) workaround:

     

     

     

                  Date date3 = rsp.getModTime();
                  date3.setTime(date3.getTime() * 1000);
                  DateFormat format3 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
                  String formatted3 = format3.format(date3);
                  System.out.println("FIXED  Modification Time: " + formatted3);

     

     

    I am hopeful the support answer will be to update the code, but wonder if this will backfire for those who have already found and implemented this fix.

     

     

    FIXED  Modification Time: 12/29/2014 15:46:03