How do I use packed decimal values in a Java program?
In Java, the best way to represent decimal numbers is by using the com.ibm.math.BigDecimal class. It is included with all IBM JVMs (including the one for OS/390 and z/OS) and provides a superior decimal implementation over java.math.BigDecimal. JSR13 proposes to make this a part of Java itself. To convert numbers to BigDecimal from a byte array containing a packed decimal number, I use a routine that travels down the byte array and builds a StringBuffer to pass to the BigDecimal constructor. I’m going to experiment with some other techniques that may be more efficient but that is what I’m using for now.