Java BCD Convert To bcd2String(byte[] bytes)

Here you can find the source of bcd2String(byte[] bytes)

Description

bcd String

License

Open Source License

Declaration

private static String bcd2String(byte[] bytes) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static String bcd2String(byte[] bytes) {
        char temp[] = new char[bytes.length * 2], val;

        for (int i = 0; i < bytes.length; i++) {
            val = (char) (((bytes[i] & 0xf0) >> 4) & 0x0f);
            temp[i * 2] = (char) (val > 9 ? val + 'A' - 10 : val + '0');

            val = (char) (bytes[i] & 0x0f);
            temp[i * 2 + 1] = (char) (val > 9 ? val + 'A' - 10 : val + '0');
        }/*w  ww  . j a v  a2s  . com*/
        return new String(temp);
    }
}

Related

  1. BCD2ASC(byte[] bytes)
  2. bcd2Ascii(byte[] bytes)
  3. bcd2str(byte[] b)
  4. bcd2str(byte[] b, int offset, int len, boolean padLeft)
  5. bcd2Str(byte[] bytes)
  6. bcdNibbleToInt(byte b, boolean high)
  7. bcdToByte(byte src)
  8. BCDtoInt(int bcd)
  9. BCDToLong(byte[] bcdByte)