Need assistance with a weight field

I was asked to do the below and I’m having a hard time figuring out how to accomplish the request. Seems that it would involve a lot of branch and sequences, but I’m not sure. If anyone can help, I will very much appreciate it.

The request:

For the weight field I need for the field to store with an implied decimal position of one; zero filled to the left and to right if no decimal value is present…

Examples: 22.5 = 0225

                22 =  0220

              123.5 = 1235

               123 =  1230

Check out pub.string:numericFormat. But you may need to resort to creating a Java service to get implied decimal notation. I can’t recall. I also can’t recall which Java class supports implied decimals. Perhaps a quick Google search would help?

This is an instance where I feel a Java service is perfectly appropriate. Writing this in FLOW might be interesting, but there’s probably little value in doing so.

1)multiply 10 to the input value “pub.math:multiplyFloats”

2)pub.string:Numericformat (pattern:‘0000’###)

3)pub.string:padleft( length:4, padstring: )

Try this and let me know.


Be careful with multiplyFloats. As mentioned in other posts and in this eZine article the use of floating point operations can result in inaccurate numeric values.

You might consider using java.util.BigDecimal to move the decimal point. Then convert the BigDecimal object to a string and then format as Ram describes.