Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution.
READ ALL ABOUT IT!
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.
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;
}}
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