String to Date Conversion in Talend

Highlighted
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"));

View solution in original post


All Replies
Highlighted
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"
Highlighted
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"));

View solution in original post

Highlighted
Seven Stars

Re: String to Date Conversion in Talend

Thanks @Dijke

[Solved]

Works very fine to me 

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog