- openHAB version: 3.2
I’m struggling with JS standard, built-in String.prototype.padStart() method.
I’m using the scripting scratchpad to run this code:
var logger = Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.rule." + ctx.ruleUID);
var x = 18;
logger.info(x.toString());
logger.info(x.toString().padStart(3,'0'));
So I’m currently using this:
logger.info(("000" + x.toString()).substr(-3,3));
Anyone with a working code maybe? That would be great, thanks.