Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a file with the following format:
203147_TMBreakdown_Aug29_2018-Aug31_2018_20180901
204780_TMBreakdown_Sep17_2018-Sep18_2018_20180920
I'd like to parse out the first date in the filename as YYYY-MM-DD or DD/MM/YY
In the two filenames above:
Aug29_2018 ----> 2018-08-29 or 29/08/18
Sep17_2018 ----> 2018-09-17 or 17/09/18
Could anyone help me on how to do this? I'm fairly new to Talend.
Thanks
If you can guarantee your incoming format will always be consistent the following will work in a tJavaRow component:
String data = row1.data; row2.start = data; //extract date from string String extracted = data.substring(data.indexOf("_",data.indexOf("_") + 1) + 1,data.indexOf("-")); row2.extracted = extracted; //extract date formatted Date d = TalendDate.parseDate("MMMdd_yyyy", extracted); row2.finalDate = TalendDate.formatDate("yyyy-MM-dd", d);
Thank you so much! I will try this as soon as I get home.
Thanks again