Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Parse char to timestamp

Hi,

I have a table column with char data type and below is the value. Now I need to convert this to a date data type. I am trying to use TalendDate.parseDate and TalendDate.formatDate combination to achieve this. Can you please help how to get this done? Appreciate the help! 

 

Source Value - 2020-04-12-23.43.00.013342

 

Code trying to use:

TalendDate.parseDate("yyyy-MM-dd-HH.mm.ss.ssssss",row7.OPPORTUNITYID.trim())

Labels (3)
6 Replies
manodwhb
Creator III
Creator III

how are you getting as char? Really not understand and the below expression is to convert string to date.

TalendDate.parseDate("yyyy-MM-dd-HH.mm.ss.ssssss",row7.OPPORTUNITYID.trim())
Anonymous
Not applicable
Author

Hi Manohar,

 

let me put it this way. 

 

i have a column as char data type with value "2020-04-12-23.43.00.013342" on it. 

Now i need to convert this to DATE datatype by keeping the same format of the value. 

please let me know how this can be done. 

 

manodwhb
Creator III
Creator III

First convert char to sting and then you try to use expression, which you have.
Anonymous
Not applicable
Author

I stand corrected that my source format is actually string not char. I used below command. 

 

source - 2020-04-12-23.43.00.013342

TalendDate.parseDateInUTC("yyyy-MM-dd-HH.mm.ss.ssssss",row7.OPPORTUNITYID) 

output - 2020-04-12-23.25.22.000022

 

tMap output definition. 

0683p000009M9HP.png

 

i am not sure why mm.ss.ssssss part is getting changed.

ganeshK
Contributor
Contributor

Hi Prabav, I am also facing same issue mm.ss.ssssss part is getting changed. Have you resolved this issue?

gjeremy1617088143
Creator III
Creator III

Hi , the java Time class don't support nanosecond.

the max you can use is for millisecond.

You can use the LocalDateTime class instead

Send me Love and Kudos