String to Date Conversion in Talend

Seven Stars

String to Date Conversion in Talend

How to Convert this "Tue, 26 Jun 2018 09:00:15 -0500" {Datatype - String} into "20180626" {Datatype - String
and another is 

How to Convert this "Wed Jun 27 15:57:11 IST 2018" {Datatype - String} into "20180626" {Datatype - String

 

 

By Using TalendDate.parseDate it throws Unparsable Date error  !!


Accepted Solutions
Ten Stars

Re: String to Date Conversion in Talend

Sorry, copy pasted wrong code.

System.out.println(TalendDate.parseDate("EEE, dd MMM yyyy HH:mm:ss Z","Thu, 21 Jun 2018 12:22:00 -0500"));

System.out.println(TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy","Wed Jun 27 15:57:11 IST 2018"));

All Replies
Ten Stars

Re: String to Date Conversion in Talend

"Tue, 26 Jun 2018 09:00:15 -0500" use this format : "E, dd MMM yyyy HH:mm:ss XXX"
"Wed Jun 27 15:57:11 IST 2018" use this format : "E MMM dd HH:mm:ss Z yyyy"
Seven Stars

Re: String to Date Conversion in Talend

@Dijke

 

I'm getting this error

Exception in component tFileCopy_6 (FetchFromGmail)
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "Thu, 21 Jun 2018 09:00:31 -0500"
at routines.TalendDate.parseDate(TalendDate.java:898)
at routines.TalendDate.parseDate(TalendDate.java:842)
at delwarejob.fetchfromgmail_0_1.FetchFromGmail.tPOP_5Process(FetchFromGmail.java:1506)
at delwarejob.fetchfromgmail_0_1.FetchFromGmail.runJobInTOS(FetchFromGmail.java:2185)
at delwarejob.fetchfromgmail_0_1.FetchFromGmail.main(FetchFromGmail.java:1807)
Caused by: java.text.ParseException: Unparseable date: "Thu, 21 Jun 2018 09:00:31 -0500"
at java.text.DateFormat.parse(Unknown Source)
at routines.TalendDate.parseDate(TalendDate.java:884)
... 4 more

Ten Stars

Re: String to Date Conversion in Talend

Sorry, copy pasted wrong code.

System.out.println(TalendDate.parseDate("EEE, dd MMM yyyy HH:mm:ss Z","Thu, 21 Jun 2018 12:22:00 -0500"));

System.out.println(TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy","Wed Jun 27 15:57:11 IST 2018"));
Seven Stars

Re: String to Date Conversion in Talend

Thanks @Dijke

[Solved]

Works very fine to me 

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads