[resolved] UnParseable Date format

One Star

[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

Accepted Solutions
One Star

Re: [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

I use pattern "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" for XML date with miliseconds and timezone, without miliseconds it should be "yyyy-MM-dd'T'HH:mm:ssXXX"

All Replies
One Star

Re: [resolved] UnParseable Date format

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

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/java/text/SimpleDateFormat.html
One Star

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
One Star

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
One Star

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
One Star

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:
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
One Star

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
One Star

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?
One Star

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
One Star

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?
One Star

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
Seven Stars

Re: [resolved] UnParseable Date format

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

Re: [resolved] UnParseable Date format

Hi I am getting Unparseable date: "Start_Date__c".
And in failure file I am getting
'09/09/2011' is not a valid value for the type xsd:dateSmiley Frustratedtart_Date__c --
this error please help me
One Star

Re: [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

I use pattern "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" for XML date with miliseconds and timezone, without miliseconds it should be "yyyy-MM-dd'T'HH:mm:ssXXX"
Four Stars

Re: [resolved] UnParseable Date format

Hi all,

 

i have tried all the suggestions from the comments  and still facing the issue.

I am getting the DateTime values from xml as (2019-01-13T11:35:28-05:00).

Unable to load this value directly, when loaded as string unable to convert this value from stringToDate.

 

Please suggest a solution or date pattern for this kind of value.

 

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch