I am trying to format a number using java.text.DecimalFormat in SSJS but it returns an error. Here is my code snippet.
var df:java.text.DecimalF
It does not work because SSJS cannot tell the difference between double and float (this is by design - javascript has only concept of number with 64 bit precision).
You can probably hack this with reflection:
var df:java.text.DecimalFormat = new java.text.DecimalFormat("000");
df.getClass().getMethod("format", Double.class).invoke(df, 50);
But I would rather create some custom java utils classes for this purpose. SSJS is awful for almost anything except for calling java.