Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

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

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

No idéas??
No suggestions???
Highlighted
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
Highlighted
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

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog