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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

TalendDate.parse returns unexpected result

The following expression,
TalendDate.parseDate("yyyy-MMM-dd HH:mm:ss", "23-Mar-1979 23:59:59")
gives me the output:
Fri Jul 30 23:59:59 CET 28
I wonder why is it giving me such an output.

OS: Windows XP
Current Locale: Sweden
Talend ETL : 2.3.1
Labels (2)
11 Replies
Anonymous
Not applicable
Author

Hi Umair,
You try to parse a Date with a String value but a wrong DatePattern.
When you parseDate you need to have the same Pattern for your String value to parse in a Date object your data.
Best regards;
Anonymous
Not applicable
Author

Why does the above example not throw an exception?
Rgds
Anonymous
Not applicable
Author

Normally, it's throw an exception.
Maybe umair has not written the same expression that wrong result displayed.
Best regards,
Anonymous
Not applicable
Author

The example, TalendDate.parseDate("yyyy-MMM-dd HH:mm:ss", "23-Mar-1979 23:59:59")
is quoted in TalendDate routine comments.
But, now i changed the values and tried with the updated params:
TalendDate.parseDate("yyyy-mm-dd HH:mm:ss", "1979-04-11 23:59:59")
It now gives :
Thu Jan 11 23:59:59 CET 1979
The month is displayed as something else
Anonymous
Not applicable
Author

It's because your pattern is wrong, for month use the MM and not the mm (mm is for minute) in your Pattern.
Best regards.
Anonymous
Not applicable
Author

yes, that worked.
Thanx for your help
Anonymous
Not applicable
Author

Hi,
I have a date in following format.
Tue Nov 01 12:36:40 GMT+05:30 2011
I tried to parse it using following statement in tJava component
TalendDate.parseDate("yyyy-mm-dd HH:mm:ss",input_row.mtime_string);
This input_row.mtime_string string comes from tfileProperties.
It returns following exception
Exception in component tJavaRow_1
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "Tue Nov 01 12:36:40 GMT+05:30 2011"
Whether am in missing something ?
Vaibhav
Anonymous
Not applicable
Author

Hi,
Solution to above query is following expression.
TalendDate.formatDate("yyyy-mm-dd hh:mm:ss",TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy","Tue Nov 01 12:36:40 GMT+05:30 2011"))
Contributed by Diwakar Nahata.
Thanks
Vaibhav
Anonymous
Not applicable
Author

Hi All,
TalendDate.ParseDate function in Talend to convert into Date Data type returns date in date data type but the date patterns is something else which is unexpected .
for eg.
I want to convert following string into date data type.
TalendDate.ParseDate("MM/dd/yyyy","09/18/2013")
The Above function returns me the date in date data type but the format of that is like "18-SEP-2013"
I want the output in "MM/dd/yyyy" means "09/18/2013" formats only.
can anyone suggest me how to overcome this issue.
Thank you in advance.
with kind regards,
Shailendra S.