Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
I have a string date. Eg: "20170922111613516888" and i want to convert it to Date "yyyy-MM-dd'T'HH:mm:ss'Z'".
how??
So you want to convert your String into another String formatted as you state? OK, All you need to do is take what I have given you already and wrap it in this code.....
routines.TalendDate.formatDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", routines.TalendDate.parseDate("yyyyMMddHHmmssS", "20170922111613516888"))
It looks like you may have one too many digits (too many 8s at the end?) but you can do it like below....
routines.TalendDate.parseDate("yyyyMMddHHmmssS", "20170922111613516888")You do not need to worry about formats when creating Dates by the way. A Date is a unit of time. As a Date it has no format.
But i need to convert to "yyyy-MM-dd'T'HH:mm:ss'Z'"... Eg: 2017-07-26T01:00:00Z
and my input is a String(20). Eg: 20170922111613516888
So you want to convert your String into another String formatted as you state? OK, All you need to do is take what I have given you already and wrap it in this code.....
routines.TalendDate.formatDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", routines.TalendDate.parseDate("yyyyMMddHHmmssS", "20170922111613516888"))
I've try to do like this but don't work...
[statistics] connecting to socket on port 3798
[statistics] connected
[statistics] disconnected
I think you have misunderstood what is happening there. You are converting a String to a Date and the String must be in the format that is specified by the format. Once a Date object is created, format is totally irrelevant. It is a bit like a number. A number is just a value irrespective of format you display it in. To use a Date in calculations or to put in a database, you do not need to worry about format. To display a Date, then you need to deal with the format.
Basically, change the date format in your tLogRow and you will see it in the format you want it. But first you need to identify the correct format of the String to convert it to a Date.
oh! you're right (sorry)
Now work my job! Thank you!