Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Everyone,
I'm trying to extract the data from Drupal using Talend and i'm having troubles with formatting the String date in Drupal to the Date format.
Source Date: Thu Aug 18 00:00:00 BST 2016 (Type String)
Target Date: 2016-08-18T00:00:00.000Z (Type Date)
I've tried various expressions in Talend.Date() method but couldn't figure it out yet. Do you guys have any idea about this?
Thanks,
Regards,
Hasitha
Thanks for the quick response rhall. I think i've got to a point that i can work it out.
First of all, you should be aware that the Date class stores dates as numbers. Format is irrelevant here. So you just want to convert to a Date from String. Having said that, I have included code to convert back to a String in the format you want. The code is below...
String date = "Thu Aug 18 00:00:00 BST 2016"; //Set your example date Date myDate = routines.TalendDate.parseDate("EEE MMM dd HH:mm:ss z yyyy", date); //Convert the example date to a Date //Print the Date object to a String in the format you specified System.out.println(routines.TalendDate.formatDateLocale("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", myDate, "BST"));
Thanks for the quick response rhall. I think i've got to a point that i can work it out.
Hi @hasitha, you need to accept the post which gave you the solution. Otherwise people also suffering with the same issue will not find it easily. Thanks.