Header Ads

  • Recent Posts

    How to find a file's last modified date in PeopleCode?

    To my knowledge, there is no way we could find a file's creation date or last modified date using PeopleCode. Sometimes with processes running in Process Scheduler, when it is required to find an input file's last modified date and do further processing it becomes nearly impossible since PeopleCode does not directly provide us the ability to read a file's last modified date. Since it is a file attribute and could be read from a OS, we can use Command mode from PeopleCode and read it. However, with the help of google results, I learnt that reading the file's last modified date is possible in JAVA/JSP, and I derived the below code. This code can can be used in PeopleSoft which makes use of Java Objects to read a file's last modified datetime.

    Local object &file = CreateJavaObject("java.io.File", "C:\abc.txt");
    Local object &dttm_format =
    CreateJavaObject("java.text.SimpleDateFormat", "dd/MM/yyyy HH:mm:ss");
    &modified_dt = &dttm_format.format(&file.lastModified());

    Points to note:
    • In case, date alone is enough change the date format to dd/MM/yyyy.
    • The resultant &modified_dt is a string and further data conversion needs to be run if we have to read it in PeopleSoft date, datetime formats.
    • The most important thing is that this code specified above is ABSOLUTELY CASE-SENSITIVE. Please do not alter the case as it provides errors or undesired results.

    No comments

    Please refrain for marketing messages and unnecessary back links.

    Post Top Ad

    Post Bottom Ad