While the above code works the below code shortens the lines of code by utilizing JavaScript "Compound Statements" Using compound statements can sometimes help with readability but can also make the code harder to interpret. User preference can be employed here.
The two examples below perform the date manipulation using two different JavaScript methods using date and string functions.
Example Using JavaScript Date Functions:
var PV145 = source.getNode("PV1-45");
if (StringUtils.endsWith(PV145, '000000')) {
var newDate = org.apache.commons.lang.time.DateUtils.addSeconds(qie.deduceDate(PV145), -1);
message.setNode('PV1-45', qie.formatDate('yyyyMMddHHmmss', newDate));
}
Example Using JavaScript String Functions:
var PV145 = source.getNode("PV1-45");
if (StringUtils.endsWith(PV145, '000000')) {
message.setNode('PV1-45', StringUtils.substring(PV145, 0 , -6) + '235959');
}