Skip to Content

How to read SFTP server time `

Dear All.

I would like to read the SFTP server time stamp and the same time to be posted in the Dadabase. my scenario is SFTP to JDBC. and i can see "Time Stamp" parameter in ASMA in sender adapter.

now how to get the server time stamp into my field. please do let me know is any UDF available for the same.

please note: if i enable the "timestamp" in sender SFTP channel by enabling ASAM , i can see "MTime" as i mentioned below.

<sap:Record namespace="http://sap.com/xi/XI/System/File" name="MTime">1499083669</sap:Record>

in this case, is there any way to convert Mtime to DateTime format.

please do needful.

Regards

Ramesh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jul 03, 2017 at 01:10 PM

    Hi K Ramesh!

    public static String getDateFromUnixTimeStamp(long timeStamp, String dateFormat, String timeZone) {
    if (timeStamp == 0)
    return "";
    if (dateFormat == null || dateFormat.trim().isEmpty())
    dateFormat = "yyyy-MM-dd HH:mm:ss";

    Date date = new Date(timeStamp*1000L);
    SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
    if (!(timeZone == null || timeZone.trim().isEmpty()))
    sdf.setTimeZone(TimeZone.getTimeZone(timeZone));

    return sdf.format(date);
    }

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded