#1 2008-04-04 15:49:53

besco
Member
Registered: 2007-11-09
Posts: 51

string to date

Hi,

I have a string like that "16/01/2008 09:04:12 AM" and i need to have a date from this string.
i try with TalendDate.parseDate("dd/MM/yyyy HH:mm:ss aa", madate) but it doesn't work.
the log is Unparseable date: "16/01/2008 09:04:12 AM"
Have u got an idea to help me ?

Offline

#2 2008-04-04 21:40:06

Volker Brehm
Member
Registered: 2007-04-03
Posts: 1139
Website

Re: string to date

I tried your date string with your format and it works for me. Maybe you have problems with your Locale.

For a quick test just generate a date with your format and make a visual compare.

Bye
Volker

Offline

#3 2008-04-07 04:28:53

shong
Talend team
Registered: 2007-08-29
Posts: 10359
Website

Re: string to date

Hi besco

Try this method:
TalendDate.parseDateLocale("dd/MM/yyyy HH:mm:ss aa",mydate,"EN")

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#4 2008-04-08 17:44:06

besco
Member
Registered: 2007-11-09
Posts: 51

Re: string to date

it's ok now but another problem appears when i load my date in oracle. if i have 2 date like that
16/01/2008 09:04:12 AM
16/01/2008 09:04:12 PM
there's no difference in oracle.

About date, i've another question, how can i put a default value (date of day) for a oracle column.
i try in a tmap to put this

Code:

row1.ORIGINAL_FILE_DATE.equals("null") ? TalendDate.getDate("dd/MM/yyyy hh:mm:ss") : row1.ORIGINAL_FILE_DATE

and the syntax seems to be wrong.

thanks to help me!

Offline

#5 2008-04-10 09:57:21

besco
Member
Registered: 2007-11-09
Posts: 51

Re: string to date

have you got any idea please ?

Offline

#6 2008-04-10 12:00:34

shong
Talend team
Registered: 2007-08-29
Posts: 10359
Website

Re: string to date

Hello

row1.ORIGINAL_FILE_DATE.equals("null") ? TalendDate.getDate("dd/MM/yyyy hh:mm:ss") : row1.ORIGINAL_FILE_DATE

There is no wrong on the syntax, if there are some fileds are empty in Oracle table, you can try this code:

Code:

row1.ORIGINAL_FILE_DATE==null ? TalendDate.getDate("dd/MM/yyyy hh:mm:ss") : row1.ORIGINAL_FILE_DATE

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#7 2008-04-10 14:06:09

besco
Member
Registered: 2007-11-09
Posts: 51

Re: string to date

this code is wrong

Code:

Exception in thread "Main Thread" java.lang.Error: Unresolved compilation problem: 
    Type mismatch: cannot convert from Object&Serializable&Comparable<?> to Date

Offline

#8 2008-04-11 08:41:48

shong
Talend team
Registered: 2007-08-29
Posts: 10359
Website

Re: string to date

Hi

What's the schema type of row1.ORIGINAL_FILE_DATE in your case? I thought it was string, not Date.
If it is a Date type, we should parse a string to a Date.

Code:

row1.ORIGINAL_FILE_DATE==null ? TalendDate.parseDate("dd/MM/yyyy hh:mm:ss",TalendDate.getDate("dd/MM/yyyy hh:mm:ss") ): row1.ORIGINAL_FILE_DATE

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#9 2009-07-19 13:50:05

venkatk
New member
Registered: 2009-07-17
Posts: 5

Re: string to date

Shong
I am getting the following error when I tried using the expression in tMap, row1.START_DATE_ACTIVE==null ? TalendDate.parseDate("dd/MM/yyyy hh:mm:ss",TalendDate.getDate("dd/MM/yyyy hh:mm:ss") ): row1.START_DATE_ACTIVE.

ErrorMessage:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:

Can you please let me know how I can avoid this error. Thanks in advance.

-Venkat

Offline

#10 2009-07-19 14:26:07

venkatk
New member
Registered: 2009-07-17
Posts: 5

Re: string to date

Shong,
I figured out the issue. This thread helped me to fix my issue.

Thank you,
-Venkat

Offline

#11 2010-12-06 12:13:01

anaveen
Guest

Re: string to date

hi,
how to convert string to date in tmap
my string is "06/04/2010"  but its give a error
java .lang .numberformatexception

regards,
naveen

#12 2011-01-21 17:51:50

ZeljkaMom
Member
Company: SRL Global , London
Registered: 2011-01-14
Posts: 148
Website

Re: string to date

Hi,

I have a string like that "2 November 2010" and i need to have a date from this string.
Any Idea how I can convert this using Talend ?

Thanks
Z

Offline

#13 2011-01-24 22:24:04

JohnGarrettMartin
Member
Registered: 2009-01-07
Posts: 781

Re: string to date

Please see:

http://download.oracle.com/javase/1.4.2 … ormat.html

for all your date formatting needs.

Offline

#14 2012-01-18 08:37:02

honeybakliwal
Member
Registered: 2010-07-07
Posts: 155

Re: string to date

I tried the same with variable type as date and expression as

TalendDate.parseDate("dd/MM/yyyy HH:mm:ss",row1.Target_Resolution_Date)
 
where row1.Target_Resolution_Date is of type string
in tMap component but i faced the following error

Exception in component tMap_1
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "13 12 2011 06:00:00"
    at routines.TalendDate.parseDate(TalendDate.java:643)
    at honey.create_my_first_job_0_1.Create_My_First_Job.tFileInputExcel_3Process(Create_My_First_Job.java:1566)
    at honey.create_my_first_job_0_1.Create_My_First_Job.runJobInTOS(Create_My_First_Job.java:2312)
    at honey.create_my_first_job_0_1.Create_My_First_Job.main(Create_My_First_Job.java:2186)
Caused by: java.text.ParseException: Unparseable date: "13 12 2011 06:00:00"
    at java.text.DateFormat.parse(DateFormat.java:354)
    at routines.TalendDate.parseDate(TalendDate.java:641)
    ... 3 more
[statistics] disconnected
Job Create_My_First_Job ended at 12:58 18/01/2012. [exit code=1]

Offline

#15 2012-08-07 12:08:14

naveendewase
Member
Company: cspl indore
Registered: 2011-07-22
Posts: 12

Re: string to date

hi i want to convert string 7/17/2012 2:57:16 PM to date but it gives error
Exception in component tMap_2
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "7/17/2012 2:57:16 PM"
    at routines.TalendDate.parseDateLocale(TalendDate.java:676)
    at xml_to_mysql.xml_master_data_conversion_0_1.Xml_Master_Data_Conversion.tFileInputXML_4Process(Xml_Master_Data_Conversion.java:6989)
    at xml_to_mysql.xml_master_data_conversion_0_1.Xml_Master_Data_Conversion.runJobInTOS(Xml_Master_Data_Conversion.java:8194)
    at xml_to_mysql.xml_master_data_conversion_0_1.Xml_Master_Data_Conversion.main(Xml_Master_Data_Conversion.java:8062)
Caused by: java.text.ParseException: Unparseable date: "7/17/2012 2:57:16 PM"
    at java.text.DateFormat.parse(DateFormat.java:337)
    at routines.TalendDate.parseDateLocale(TalendDate.java:674)
    ... 3 more
[statistics] disconnected

Regards,
naveen

Offline

#16 2012-09-12 18:29:17

arturogh15
Member
Registered: 2012-08-20
Posts: 17

Re: string to date

Hi
I have this problem with the convertion of a data String type to Date.
I have this value 2012-04-26T18:27:55, and i want to convert it to a Date data type
I need this format dd/mm/yyyy
This is the error message that is returnig:
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "2012-04-26T18:27:55

Offline

Board footer

Powered by FluxBB