=====Date/Time Calculations in Scripts=====
See Java documentation for package java.time and java.time.format for more ideas
==== Time from the incomingValue =====
The timestamp of the event when the incoming value object is created is stored in the value object. This time is the milliseconds from the Java epoch of 1970-01-01T00:00:00Z.
timestamp = incomingValue.getTimeMillis();
//convert time in millseconds to a local time
valueObjectTime = java.time.Instant.ofEpochMilli(timestamp);
localZonedDateTime = java.time.LocalDateTime.ofInstant(valueObjectTime, java.time.ZoneId.systemDefault());
//print this as a local time and date using a time formatter
df=java.time.format.DateTimeFormatter.ofLocalizedDateTime(java.time.format.FormatStyle.MEDIUM);
//use the formatter to make the output human readable
print("time of value object is "+df.format(localZonedDateTime));
output=df.format(localZonedDateTime);
==== Get the Current Local Time ====
For log4j logging, use a date formatter %d in the appender layout, for example:
In a script the current time can be printed using:
//simple formatter for the time
df=java.time.format.DateTimeFormatter.ofPattern("HH:mm:ss");
timenow = java.time.LocalDateTime.now();
print(df.format(timenow)+" Time of Event");