Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have 2 columns of timestamps(Date) till Milliseconds ( "yyyy-MM-dd'T'HH:mm:ssSS" format)
The Difference Output Should Be like : 0000-00-00 00:00:20:000
('Long' format is acceptable)
Thanks in advance.
Regards
Subhadeep
Hi
if (Long) acceptable, why do not use
TalendDate.diffDate(row1.strDate2,row1.strDate1,"SSS")
return (Long) number of milliseconds between dates
then you could add code to convert milliseconds to years/month/etc (if need)
Var.ms = TalendDate.diffDate(row1.strDate2,row1.strDate1,"SSS")
output (for HH:mm:ss:SSS):
String.format("%02d:%02d:%02d.%d", (Var.ms / (1000 * 60 * 60)) % 24, (Var.ms / (1000 * 60)) % 60, (Var.ms / 1000) % 60, Var.ms % 1000)
Hi @vapukov ,
First of all ,thanks a lot for your reply.
I tried with the Milliseconds approach only .
But , I need the difference output in full timestamp format, Like :
yyyy-MM-dd HH:mm:ssSS
Looking forward to hear from you.
Regards
Subhadeep
if you are using Java8 , below links will help.
https://stackoverflow.com/questions/25747499/java-8-calculate-difference-between-two-localdatetime
https://stackoverflow.com/questions/22463062/how-to-parse-format-dates-with-localdatetime-java-8