Convert String "(11 MAY 2011)" to Date

Four Stars

Convert String "(11 MAY 2011)" to Date

Hello community,

I want to convert string to date(dd/mm/yyy) ,The string has a forme (11 MAY 2011)

when i try to use the function TalendDate.parseDate("dd/mm/yyyy",row1.nomduchamps)  i get an error

Please any help 

Thanks in advance 

Five Stars

Re: Convert String "(11 MAY 2011)" to Date

Hello Lilya,

 

I tried TalendDate.parseDateInUTC("dd MMM yyyy","11 MAY 2011") and it worked.
Here as per your query the type of input argument("11 MAY 2011") is String.
I kept Data type of destination column as Date and "dd-MM-yyyy" as Date Pattern.
It returned 11-05-2011 as output
Hope it helps !!

 

Thanks,
Trupti

Four Stars

Re: Convert String "(11 MAY 2011)" to Date

i'm trying your solution(TalendDate.parseDateInUTC("dd-MMM-yy",row1.STMDMVT))

but i get this error

java.lang.RuntimeException: java.text.ParseException: Unparseable date: " "

Thinks

 

 

Forteen Stars TRF
Forteen Stars

Re: Convert String "(11 MAY 2011)" to Date

@Lilya row1.STMDMVT is probably null or empty (or may contains a space character based on your message)

TRF
Six Stars

Re: Convert String "(11 MAY 2011)" to Date

Hi Liya,
Try the following code in tmap.

TalendDate.parseDate("dd MMM yyyy",row1.DateString)
Seven Stars

Re: Convert String "(11 MAY 2011)" to Date

DateString.jpg