Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Convert format (EEE MMM dd HH:mm:ss Z yyyy) to (YYYY-MM-DD)

Hello, 
I need to convert format (EEE MMM dd HH:mm:ss Z yyyy) to (YYYY-MM-DD).
Exemple : Mon Nov 22 00:00:00 CET 2004 ----> 2004-11-22
Thanks.
Labels (2)
4 Replies
Anonymous
Not applicable
Author

Hi rrjili,

Is your input source "String" data type or "Date"?
Best regards
Sabrina
Anonymous
Not applicable
Author

J'ai ajouter le class java suivant pour résoudre le problème :
package routines;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class CONVERT_DATE {
public static Date toDate(String Str) throws ParseException  {
DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.US);
Date date1 = (Date)formatter.parse(Str); 
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
return date1;      
   
}}
Anonymous
Not applicable
Author

Hi! I have the same problem and for me the data type is a string. Thanks for helping! @xdshi 

Anonymous
Not applicable
Author

@Gerard_BA 

 

Please refer the below method to convert the string to date in different format.

0683p000009M7ec.png

 

0683p000009M7al.png

 

The function used is as shown below.

 

TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy",row1.data) 

If you need to convert the output again to String, you can use a tConvertType component or any java string conversion function.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved