We store time in a numeric field (6,0) (HHMMSS format). Is there a way to force leading zeros in a number when using ".toString". I didn't see anything in Valence APIs for converting a number with leading zeros. The code below works but I didn't know if there was a better method.
Code:
var atime = value.toString();
if (atime.length < 2) {
atime = '00000' + atime;
}
if (atime.length < 3) {
atime = '0000' + atime;
}
if (atime.length < 4) {
atime = '000' + atime;
}
if (atime.length < 5) {
atime = '00' + atime;
}
if (atime.length < 6) {
atime = '0' + atime;
}
return atime.substr(0,2) + ':' + atime.substr(2,2) + ':' + atime.substr(4,2);

Comment