Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III

[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
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

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"

View solution in original post

15 Replies
_AnonymousUser
Specialist III
Author

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

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
_AnonymousUser
Specialist III
Author

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
_AnonymousUser
Specialist III
Author

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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?
Anonymous
Not applicable

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