One Star

TalendDate format string for timestamp with timezone

Hi
I have the following code in a tMap - TalendDate.parseDate("yyyy-MM-dd'T'hh:mm:ssz", stgTVP6.MOMENT ) .
When it runs, I get the following error
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "2004-08-12T00:00:00+09:30"
Can someone help me with the correct format string for a timestamp string with the format "2004-08-12T00:00:00+09:30".
Thanks
Mario
7 REPLIES
Five Stars

Re: TalendDate format string for timestamp with timezone

try this one
String date = "2004-08-12T00:00:00+09:30".replaceAll("\\+0(){1}\\:00", "+0$100");
System.out.println( TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ssZ", date));
One Star

Re: TalendDate format string for timestamp with timezone

Thanks, but I'm still getting exactly the same error. When I check the effect of the replaceAll on the input value, it hasn't changed the input string at all.
I'm not very good at regular expressions - what are you trying to replace, and with what?
Seven Stars

Re: TalendDate format string for timestamp with timezone

"z" in a date format string is e.g. GMT, PST. "Z" in a date format string is a time offset e.g. +1000. So you should just need to get rid of the ":" in the time offset and change your date format string to use "Z".
Try:
TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ssZ", stgTVP6.MOMENT.replaceAll("Smiley Sad\\d{2})$","$1"));
One Star

Re: TalendDate format string for timestamp with timezone

Thanks.
That worked insofar as as making the timestamp value palatable to Talend. The problem is that ParseDate now insists on converting the time zone from +9:30 (South Australia) to Eastern European time!!
Seven Stars

Re: TalendDate format string for timestamp with timezone

How do you mean?
One Star

Re: TalendDate format string for timestamp with timezone

I mean that if I give it a value of "2013-06-16T10:00:00+09:30", I get back a value of "2013-06-16T03:00:00+0300" - both effectively the same time, but one is in Adelaide and the other in Eastern Europe - possibly Prague, but it could be Budapest.
Seven Stars

Re: TalendDate format string for timestamp with timezone

I can only imagine that the machine you're running the job on thinks it's in the +3 timezone.