[resolved] parseDate and "MMM" pattern

One Star

[resolved] parseDate and "MMM" pattern

Hello all,
I found on Forum how to parse a date like "Jun 30 12 12:16:45"
so, I tried :
TalendDate.parseDate("MMM dd HH:mm:ss","Jun 30 12:16:45");

And finally this exception occurs:
Exception in component tJavaRow_6
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "Jun 30 12:16:45"

I don't understand where is the problem... My pattern seams to be correct.
Thanks,

Accepted Solutions
One Star

Re: [resolved] parseDate and "MMM" pattern

Try:
(Relational.ISNULL(row5.Fecha_Entr_Prog))? TalendDate.parseDateLocale("yyyy-MM-dd HH:mm:ss","2013-02-09","EN") : TalendDate.parseDateLocale("yyyy-MM-dd",row5.Fecha_Entr_Prog,"EN")

All Replies
One Star

Re: [resolved] parseDate and "MMM" pattern

Hi,
may be a problem with your locale. If it isn't set to English this wouldn't work i guess. Try to set a locale. I'm not sure but may be there is a method for parseDate which will allow a locale as parameter.
Bye
Volker
Community Manager

Re: [resolved] parseDate and "MMM" pattern

Hello guy
Try
TalendDate.parseDateLocale("MMM dd HH:mm:ss","Jun 30 12:16:45","en");

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] parseDate and "MMM" pattern

It was exactly the problem. If the locale isn't set, the date couldn't be parsed.
So, it's better to use directly parseDateLocal instead of a simply parseDate.
Thanks you!
One Star

Re: [resolved] parseDate and "MMM" pattern

I ma tring to convert a date which is in string format to dd/mm/yyyy format.Please tell me the method in which i can do this
One Star

Re: [resolved] parseDate and "MMM" pattern

TalendDate.parseDate("dd/mm/yyyy",Your Date);
This should parse your string to a date ..... also make changes to column where you are going to have this date,in Talend as well as in DB if you are passing it in DB.
One Star

Re: [resolved] parseDate and "MMM" pattern

Hola a todos tengo el siguiente problema
utilizo la siguiente funcion
(row5.Fecha_Entr_Prog.equals("null"))? TalendDate.parseDateLocale("yyyy-MM-dd HH:mm:ss","2013-02-09","EN") : TalendDate.parseDateLocale("yyyy-MM-dd",row5.Fecha_Entr_Prog,"EN")
con el fin de evitar los null's pero cuando ejecuto la ETL me genera el siguiente error

java.lang.StringIndexOutOfBoundsException: String index out of range: 4
at java.lang.String.substring(Unknown Source)
si alguien me puede ayudar
One Star

Re: [resolved] parseDate and "MMM" pattern

Try:
(Relational.ISNULL(row5.Fecha_Entr_Prog))? TalendDate.parseDateLocale("yyyy-MM-dd HH:mm:ss","2013-02-09","EN") : TalendDate.parseDateLocale("yyyy-MM-dd",row5.Fecha_Entr_Prog,"EN")
One Star

Re: [resolved] parseDate and "MMM" pattern

Thankl you very much  it work
TalendDate.parseDateLocale("EEE MMM d HH:mm:ss zzz yyyy", "Sun Mar 06 11:28:16 IST 2011","en") 
One Star

Re: [resolved] parseDate and "MMM" pattern

Thankl you very much  it work
TalendDate.parseDateLocale("EEE MMM d HH:mm:ss zzz yyyy", "Sun Mar 06 11:28:16 IST 2011","en")