dk.vajhoej.record
Class BCDUtil

java.lang.Object
  extended by dk.vajhoej.record.BCDUtil

public class BCDUtil
extends java.lang.Object

Class TimeUtil converts between bytes with Binary Coded Decimals ant BigDecimal objects.


Field Summary
static byte ASCII
          ASCII zone nibble.
static byte EBCDIC
          EBCDIC zone nibble.
static byte ZERO
          Zero zone nibble.
 
Constructor Summary
BCDUtil()
           
 
Method Summary
static java.math.BigDecimal decodePackedBCD(byte[] b, int decimals)
          Convert from packed BCD to BigDecimal.
static java.math.BigDecimal decodeZonedBCD(byte[] b, byte zone, int decimals)
          Convert from zoned BCD to BigDecimal.
static byte[] encodePackedBCD(java.math.BigDecimal v, int decimals, int length)
          Convert from BigDecimal to packed BCD.
static byte[] encodeZonedBCD(java.math.BigDecimal v, byte zone, int decimals, int length)
          Convert from BigDecimal to zoned BCD.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

public static final byte ZERO
Zero zone nibble.

See Also:
Constant Field Values

EBCDIC

public static final byte EBCDIC
EBCDIC zone nibble.

See Also:
Constant Field Values

ASCII

public static final byte ASCII
ASCII zone nibble.

See Also:
Constant Field Values
Constructor Detail

BCDUtil

public BCDUtil()
Method Detail

decodePackedBCD

public static java.math.BigDecimal decodePackedBCD(byte[] b,
                                                   int decimals)
Convert from packed BCD to BigDecimal.

Parameters:
b - bytes with packed BCD
decimals - implied decimals
Returns:
BigDecimal object

encodePackedBCD

public static byte[] encodePackedBCD(java.math.BigDecimal v,
                                     int decimals,
                                     int length)
Convert from BigDecimal to packed BCD.

Parameters:
v - BigDecimal object
decimals - implied decimals
length - length
Returns:
byte array with packed BCD

decodeZonedBCD

public static java.math.BigDecimal decodeZonedBCD(byte[] b,
                                                  byte zone,
                                                  int decimals)
Convert from zoned BCD to BigDecimal.

Parameters:
b - bytes with zoned BCD
zone - zone nibble value
decimals - implied decimals
Returns:
BigDecimal object

encodeZonedBCD

public static byte[] encodeZonedBCD(java.math.BigDecimal v,
                                    byte zone,
                                    int decimals,
                                    int length)
Convert from BigDecimal to zoned BCD.

Parameters:
v - BigDecimal object
zone - zone nibble value
decimals - implied decimals
length - length
Returns:
byte array with zoned BCD