Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm using tJava component to set a context variable to add additional 10 seconds to the current date and have the context variable to be date format.
This is what I got so far:
context.CurrentDate = TalendDate.getDate("yyyy-MM-dd HH:mm:ss.SSS");
System.out.println("Current Date Is: "+context.CurrentDate);
NOTE: context.CurrentDate is string type, but would like the results in datetype.
You Should Have to change the format of the date to see whether the 10ms is added are not.
Use the below code to test.
#code
String Date1 = TalendDate.getDate("yyyy-MM-hh mm:ssSS").toString();
System.out.println(TalendDate.getDate("yyyy-MM-hh mm:ssSS"));
System.out.println(TalendDate.addDate(Date1,"yyyy-MM-hh mm:ssSS", 10, "SSS"))
emoji value (Semicolon and S)
;
If this is what you are looking for then, Press the "Accept as Solution " Button and Give A Kudos
Thanks,
AR
TalendDate.addDate(TalendDate.getCurrentDate(),10,"ss")
The code above will add 10 secs to the current date. I confirmed this by defining a global variable with that formula.
addDate() returns a Date object. If you want to retain that, be sure to store the value in a Date variable. Global variables don't have an explicit type, so if you store the value to a global var, make sure you cast it to a (Date) when you retrieve the value.
Sorry, I meant to add 10 milliseconds to it.
Used your code from seconds conversion to milliseconds and I'm not getting milliseconds.
I need the context.CurrentDate and context.CurrentDatePlus1ms to be date, but have
it in this format: 2019-11-16 10:06:19.642
context.CurrentDate = TalendDate.getCurrentDate();
System.out.println("Current Date: "+context.CurrentDate);
context.CurrentDatePlus1ms = TalendDate.addDate(context.CurrentDate,1,"SSS");
System.out.println("Current Date With 1ms Is: "+context.CurrentDatePlus1ms);
Output from the code:
Current Date: Wed Nov 06 15:34:32 CST 2019
Current Date With 1ms Is: Wed Nov 06 15:34:32 CST 2019
You Should Have to change the format of the date to see whether the 10ms is added are not.
Use the below code to test.
#code
String Date1 = TalendDate.getDate("yyyy-MM-hh mm:ssSS").toString();
System.out.println(TalendDate.getDate("yyyy-MM-hh mm:ssSS"));
System.out.println(TalendDate.addDate(Date1,"yyyy-MM-hh mm:ssSS", 10, "SSS"))
emoji value (Semicolon and S)
;
If this is what you are looking for then, Press the "Accept as Solution " Button and Give A Kudos
Thanks,
AR