Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Date formatting

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

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Thanks for the quick response rhall. I think i've got to a point that i can work it out.

View solution in original post

3 Replies
Anonymous
Not applicable
Author

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"));
Anonymous
Not applicable
Author

Thanks for the quick response rhall. I think i've got to a point that i can work it out.

Anonymous
Not applicable
Author

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.