• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] UnParseable Date format

#1 2010-02-03 17:08:44

San Solai
Guest

[resolved] UnParseable Date format

Can someone get me right date format pattern for the below date style. I get this format in my XML feed and find a right pattern.

"2013-09-26T00:00:00-05:00"
"2014-09-26T00:00:00-05:00"
"2015-09-26T00:00:00-05:00"


Thanks

#2 2010-02-03 19:15:41

San Solai
Guest

Re: [resolved] UnParseable Date format

Any suggestions would be really helpful. I tried few possibilities and all throws up errors.

#3 2010-02-03 20:39:49

Serpico
Member
Registered: 2010-01-25
Posts: 16
Website

Re: [resolved] UnParseable Date format

San Solai,

The date format is the following: yyyy-MM-ddThh:mm:ssz

Most probably it is a GMT time zone.
Hour could be different, it might be HH for example, so you need to check your specifications.

More information can be found in this link: http://java.sun.com/j2se/1.4.2/docs/api … ormat.html

Offline

#4 2010-02-03 22:04:12

San Solai
Guest

Re: [resolved] UnParseable Date format

I tried that option it doesn't work. I used this "yyyy-MM-dd'T'hh:mm:ssz" (you need single quotes for 'T'), but throws

Unparseable date: "2006-12-29T00:00:00-06:00"    I think the timezone is the culprit, the date format I have does not specify any timezone like "GMT" or others.

The document says, "z" can be applied to

z      Time zone     General time zone      Pacific Standard Time; PST; GMT-08:00
Z     Time zone     RFC 822 time zone     -0800

#5 2010-02-03 22:47:44

San Solai
Guest

Re: [resolved] UnParseable Date format

I finally got this to working using Java, by adding the TimeZone(GMT) string to the date string and then apply the date conversion.

Thanks

#6 2010-02-25 07:38:06

Naju
Member
Registered: 2009-08-13
Posts: 56

Re: [resolved] UnParseable Date format

Hi All,

I tried converting the values from StringToDate with the following code in order to convert values from String format say example 2009-04-26T00:00:00-05:00 GMT to Date through Talend. I have very little work experience in Java.

I used the following code in tMap expression to convert the values from String to specify Date format "yyyy-MM-dd'T'hh:mm:ss z"

Code:
-------

DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss z");
try
{
Date today = df.parse(row1.Date_TimeZone);             
System.out.println(df.format(today));
} catch (ParseException e)
{
e.printStackTrace();
}

It throws an error as DateFormat cannot be resolved

My source is a flatfile which holds the data and my target is a relational table.

Any input is appreciated

Thanks in Advance
Naju

Offline

#7 2010-02-25 18:58:20

rdagher
Member
Company: ALDO Group
Registered: 2010-02-15
Posts: 26
Website

Re: [resolved] UnParseable Date format

Hi Naju,

You don't need to use the SimpleDateFormat class. You can use the embedded TalendDate class for that:

Code:

try
{ 
Date today = TalendDate.parseDate("yyyy-MM-dd'T'hh:mm:ss z", row1.Date_TimeZone);

//for testing purposes
System.out.println(today.toString());
} catch (ParseException e)
{
e.printStackTrace();
}

Regards,
Rabih Dagher

Offline

#8 2010-02-26 06:38:38

Naju
Member
Registered: 2009-08-13
Posts: 56

Re: [resolved] UnParseable Date format

Hi Rabih,

Thanks for your valuable response

When I substituted my with yours code.

TALEND GENERATED CODE:

Var.TimeZone = try
{
Date today = TalendDate.parseDate("yyyy-MM-dd'T'hh:mm:ss z", row1.Date_TimeZone);
System.out.println(today.toString());
}catch (ParseException e)
{
e.printStackTrace();

It's throwing me the following error

ERROR:

syntax error on token(s) misplaced construct(s).

I tried to find out the answers for this error in many blogs but it really did not help me

Thanks
Naju

Offline

#9 2010-02-26 17:51:12

rdagher
Member
Company: ALDO Group
Registered: 2010-02-15
Posts: 26
Website

Re: [resolved] UnParseable Date format

Naju,

Can you post some pictures of your job?

If you are doing it in a tMap, I would suggest you do it without the try/catch statement, and use directly the statement TalendDate.parseDate("yyyy-MM-dd'T'hh:mm:ss z", row1.Date_TimeZone);

Where exactly in your code you are doing this?

Offline

#10 2010-03-01 10:22:40

Naju
Member
Registered: 2009-08-13
Posts: 56

Re: [resolved] UnParseable Date format

Hi Rdagher,

I handled that expression in tMap component. I also changed the code by removing try and catch exception retaining TalendDate.parseDate function.

"TalendDate.parseDate("yyyy-MM-dd'T'hh:mm:ss z", row1.Date_TimeZone);  "

Please see the screenshots.

Thanks for the reply. Hoping for a solution

Regards
Naju


Uploaded Images

Offline

#11 2010-03-01 21:24:52

rdagher
Member
Company: ALDO Group
Registered: 2010-02-15
Posts: 26
Website

Re: [resolved] UnParseable Date format

Naju,

Try removing the ; from your expression.

Note: you also have to make sure that your row1.Date_TimeZone follows that exact time pattern. 

Can you post an example of a row1.Date_TimeZone value that you are using?

Offline

#12 2011-01-05 13:40:26

Arun Kandala
Guest

Re: [resolved] UnParseable Date format

Hi,
     I am using file delimited txt file  and made a row map with db connection using tmap.

I have on column of data type string  contains value like this "28-OCT-10"
so my query is how can i parse it to valid date format
to be inserted into the database

#13 2011-01-06 07:22:40

alevy
Member
Registered: 2009-11-20
Posts: 1920

Re: [resolved] UnParseable Date format

TalendDate.parseDate("dd-MMM-yy",<row.col>)

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] UnParseable Date format

Board footer

Powered by FluxBB