Timestamp format - "dd-MM-yyyy HH:mm:ss.SSSZ"

One Star

Timestamp format - "dd-MM-yyyy HH:mm:ss.SSSZ"

In a firebird datbase I have the following date:
2015-07-07 21:30:59.4300 
I need to compare with another date
How to convert it to timestamp ?
I have try TalendDate.parseDate("yyyy-mm-dd HH:mm:ss.SSSS",row1.LDATE )
and I get:
Exception in component tMap_1
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "M"
    at routines.TalendDate.parseDate(TalendDate.java:864)
    at routines.TalendDate.parseDate(TalendDate.java:808)
    at pmibrowser.test_0_1.test.tFirebirdInput_1Process(test.java:1223)
    at pmibrowser.test_0_1.test.runJobInTOS(test.java:1816)
    at pmibrowser.test_0_1.test.main(test.java:1624)
Caused by: java.text.ParseException: Unparseable date: "M"
    at java.text.DateFormat.parse(Unknown Source)
    at routines.TalendDate.parseDate(TalendDate.java:850)
    ... 4 more
What is the right way to do it?
Thanks
Didier
Five Stars

Re: Timestamp format - "dd-MM-yyyy HH:mm:ss.SSSZ"

Hi,
Try changing your date pattern from yyyy-mm-dd to yyyy-MM-dd.    
Hope that helps.
Tom
One Star

Re: Timestamp format - "dd-MM-yyyy HH:mm:ss.SSSZ"

TalendDate.parseDate("yyyy-MM-dd HH:mm:ss.SSSS",row1.LDATE )

same error:
Exception in component tMap_1
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "M"
    at routines.TalendDate.parseDate(TalendDate.java:864)
    at routines.TalendDate.parseDate(TalendDate.java:808)
    at pmibrowser.test_0_1.test.tFirebirdInput_1Process(test.java:1223)
    at pmibrowser.test_0_1.test.runJobInTOS(test.java:1816)
    at pmibrowser.test_0_1.test.main(test.java:1624)
Caused by: java.text.ParseException: Unparseable date: "M"
    at java.text.DateFormat.parse(Unknown Source)
    at routines.TalendDate.parseDate(TalendDate.java:850)
    ... 4 more
di
One Star

Re: Timestamp format - "dd-MM-yyyy HH:mm:ss.SSSZ"

No idéas??
No suggestions???
One Star

Re: Timestamp format - "dd-MM-yyyy HH:mm:ss.SSSZ"

I have tested the following syntax:
"dd-MM-yyyy HH:mm:ss.SSSZ"
I have the same error
Five Stars

Re: Timestamp format - "dd-MM-yyyy HH:mm:ss.SSSZ"

Hi,
Sorry for the delay, I have been wrapped up in a project.  Question - are you trying to parse the actual date value or have you converted the date value to a string first?  I ask because you cannot parse a date type field, you need to provide a string version of it. 
Below is the narrative from the Talend parseDate 'method'
Parses text from the beginning of the given string to produce a date using the given pattern and the default date format symbols for the given locale. The method may not use the entire text of the given string.
@param pattern the pattern to parse.
@param stringDate A string whose beginning should be parsed
@return A date parsed from the string 

Let me know if you are already using a string value to parse from and if not, convert the date to a string variable and try that out.
Tom