Skip to content

Utils API

Utils API contains small utility helpers: UUID generation, date, bit operations, number formatting, string padding.

Generates a fresh UUID string.

var id = ins.uuid();
// → "f4cbb047-4376-4d8b-ae46-5cafed31155b"

Returns the server’s current time as a Date.

var n = ins.now();
// → Wed Apr 23 00:15:42 TRT 2026

Returns the Date that corresponds to the given epoch millisecond.

var yesterday = ins.getDate(Date.now() - 86400000);
var oneHourAgo = ins.getDate(Date.now() - 3600000);

Reads a specific bit (0 = rightmost) from a Long — returns Boolean.

var statusWord = ins.getVariableValue("status_register").value;
var bit3 = ins.getBit(statusWord, 3); // true | false

Flips a specific bit of a Long — returns the new Long (the original is unchanged).

var word = 0;
word = ins.setBit(word, 0, true); // bit 0 = 1 → 1
word = ins.setBit(word, 3, true); // bit 3 = 1 → 9

Pads the string on the left with padChar to reach len.

ins.leftPad("42", 5, "0"); // → "00042"
ins.leftPad("AB", 4, " "); // → " AB"

ins.formatNumber(number, pattern, decimalSeparator, groupingSeparator)

Section titled “ins.formatNumber(number, pattern, decimalSeparator, groupingSeparator)”

Formats a number using a Java DecimalFormat pattern.

ins.formatNumber(1234567.89, "#,##0.00", ",", ".");
// → "1.234.567,89"
ins.formatNumber(3.14159, "0.00", ".", ",");
// → "3.14"