1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
495 views
by dana-h-4328 (190 points)
I have a source node with "730" and I want to pass that to the message as HHmm.  (Or, at least I need to make sure the data always gets passed thru as 4 digits.)  When I do, I get no value at all.  Code I used:

var value = source.getNode("10");
value = qie.formatDate("HHmm", value);
message.setNode("SCH-11.3", value);

I am sure my ignorance is showing!  Thank you.

1 Answer

0 votes
 
Best answer
You could left pad with zeros.

replace

value = qie.formatDate("HHmm", value);

with

value = StringUtils.leftPad(value, 4, '0');
by michael-h-5027 (14.8k points)
selected by dana-h-4328
by dana-h-4328 (190 points)
Oh shoot....The source node may have 3 or 4-digit times, so padding won't work. I forgot this part on first ask!
by michael-h-5027 (14.8k points)
leftpad will handle 3 or 4 characters. 730 would be 0730 and 1154 would be 1154 with no change.
by dana-h-4328 (190 points)
Thank you!  I can now go live.
...