Home > Mobile >  Unparseable date from tFileInputMail
Unparseable date from tFileInputMail

Time:10-05

I am trying to extract fields from emails received on a mailbox, with the idea behind to log the main elements and put them in a MySQL database. Everything is working fine except for the date, which needs to have the following format : yyyy-MM-dd HH:mm:ss

In the mails I extract in Talend, the format is like this :

Tue, 28 Sep 2021 11:16:33  0200

Which is EEE, dd MMM yyyy HH:mm:ss Z

So in my tMap, I transformed my date like this :

TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",TalendDate.parseDate("EEE, dd MMM yyyy HH:mm:ss Z",mailData.Date))

Which gives me this error : java.lang.RuntimeException: java.text.ParseException: Unparseable date: "Tue, 28 Sep 2021 14:02:56 0200"

I don't understand what I am doing wrong, could anyone give me a hint ?

CodePudding user response:

The answer was actually pretty simple :

TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",TalendDate.parseDateLocale("EEE, dd MMM yyyy HH:mm:ss Z",mailData.Date,"en")) 

My Talend is in French and the date I am trying to parse is in English, so I had to specify the locale.

  • Related