on 2019 Sep 23 9:18 AM
Hello,
Currently we have an integration which reads a CSV file from a server. We would like to read the last modified date of that file as well, in the camel file language it shows that the correct expression is ${date:modified}. However, this is not working in our integration; the property is not filled and does not show up in trace logging.
Can someone tell me whether its possible to read the last modified date of an input file and if yes, which expression is required?
Thanks in advance!
Bram
Hello Bram,
${file:modified} will get the last modified date of the file read from SFTP.Below will give the whole process you should follow to get the same in readable format.
Script to Convert from TimeObject to readable format:
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.json.*;
import groovy.xml.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.text.*;
import java.util.Date;
import java.io.*
import java.lang.*;
import java.util.*;
def Message processData(Message message) {
//Body
def body = message.getBody();
def map = message.getHeaders();
def value = map.get("FILE_MODIFIED");
Long datetimestamp = Long.parseLong(value.toString().replaceAll("\\D", ""));
Date date = new Date(datetimestamp);
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:SSS");
String dateFormatted = formatter.format(date);
map = message.getProperties();
message.setProperty("FileModifiedDate", dateFormatted);
return message;
}
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
66 | |
10 | |
10 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.