Class NumericFormatPackedDecimal


public final class NumericFormatPackedDecimal extends NumericFormatCompressed
Provides a formatter that emulates COBOL's NumericFormatPackedDecimal (COMP-3) functionality in Java. Given a decimal value and specified integer and fractional digit counts, this class: 1) encodes the value into packed decimal format (two digits per byte, high-order nibble first) 2) appends a sign nibble ('C','D','F') in the low-order nibble of the last byte 3) decodes packed decimal data back into numeric values, respecting sign and scale 4) enforces correct byte length based on total digit count This implementation delivers a reliable, high-performance Java equivalent of COBOL's packed decimal format for mission-critical data-conversion workflows.
  • Method Details

    • calculateFormattedCellSize

      public final int calculateFormattedCellSize()
    • convertFromDisplayToStorage

      public final String convertFromDisplayToStorage(double value, boolean[] sizeError)
      format a value according to the PIC definition
      Overrides:
      convertFromDisplayToStorage in class NumericFormatCompressed
    • convertFromDisplayToStorage

      public final String convertFromDisplayToStorage(BigDecimal value, boolean[] sizeError)
      format a value according to the PIC definition
      Overrides:
      convertFromDisplayToStorage in class NumericFormatCompressed
    • convertFromDisplayToStorage

      public final String convertFromDisplayToStorage(BigInteger value, boolean[] sizeError)
      format a value according to the PIC definition
      Overrides:
      convertFromDisplayToStorage in class NumericFormatCompressed
    • convertFromDisplayToStorage

      public final String convertFromDisplayToStorage(String _value, boolean[] sizeError)
      format a value according to the PIC definition
      Overrides:
      convertFromDisplayToStorage in class NumericFormatCompressed
    • convertFromStorageToDisplayFormatOld

      public final String convertFromStorageToDisplayFormatOld(String formattedString, boolean cutLeft)
      formatted string is typically a binary value eg. (chars {17, 44)) .. which in hex is {11,2c}, means decimal number 112C - where 'C' represent the sign
      Parameters:
      formattedString -
      cutLeft -
      Returns:
    • convertFromStorageToDisplayFormat

      public final String convertFromStorageToDisplayFormat(String formattedString)
      Specified by:
      convertFromStorageToDisplayFormat in class Format
    • convertFromCompressedStorageToDisplayFormat

      public final String convertFromCompressedStorageToDisplayFormat(String formattedString)
      Description copied from class: NumericFormatCompressed
      Convert from Storage-Compressed to Display This methods returns the actual stored value, even it is bigger than the defined format.
      E.g. PIC 9(2) COMP can store a value of 30000 ! This method will return "30000", but convertFromStorageToDisplayFormat will return "30".
      Specified by:
      convertFromCompressedStorageToDisplayFormat in class NumericFormatCompressed
      Returns:
    • formatHelper

      protected final String formatHelper(long value, boolean isNegative)