Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have strings in the following formats that I would like to convert into a date.
2021-05-21T11:45:15Z
2021-05-25T18:59:27.513Z
I've tried tMap with the following with no luck.
TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",row7.created_at);
Error:
Exception in component tXMLMap_1 (w_xpath_bu_testdev_wDB_dateformat)
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "2021-05-25T20:23:27Z"
Hi
If you are trying to convert UTC time to local time, please take a look at this topic and try the solution.
Let me know if it works.
Regards
Shong
It seems the data has different date format, you can check the length of string first, and then use corresponding date pattern to parse the string and convert it to Date. eg:
row7.created_at.length()>20?TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",row7.created_at):TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss'Z'",row7.created_at);
Another question, how can I convert that parsed date into local time from:
row7.created_at.length()>20?TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",row7.created_at):TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss'Z'",row7.created_at);
2020-09-27T22:34:03Z this is what I'm getting
2020-09-27 17:34:03 But I need it in this format?
I was thinking of doing something like this:
Thanks again.
Hi
If you are trying to convert UTC time to local time, please take a look at this topic and try the solution.
Let me know if it works.
Regards
Shong
Thanks I ended up doing that same thing, see my example:
I had to add the option to look for a Null first.
Relational.NOT(Relational.ISNULL(row4.created_at1))?row4.created_at1.length()>20?TalendDate.parseDateInUTC("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",row4.created_at1):TalendDate.parseDateInUTC("yyyy-MM-dd'T'HH:mm:ss'Z'",row4.created_at1):TalendDate.parseDateInUTC("yyyy-MM-dd","0000-00-00");