Java BCD Convert To bcd2Str(byte[] bytes)

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

Description

bcd Str

License

Apache License

Declaration

public static String bcd2Str(byte[] bytes) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String bcd2Str(byte[] bytes) {
        StringBuffer temp = new StringBuffer(bytes.length * 2);

        for (int i = 0; i < bytes.length; i++) {
            temp.append((byte) ((bytes[i] & 0xF0) >>> 4));
            temp.append((byte) (bytes[i] & 0xF));
        }/*from ww  w .  j av  a2 s. c  o  m*/
        return temp.toString().substring(0, 1).equalsIgnoreCase("0") ? temp.toString().substring(1)
                : temp.toString();
    }
}

Related

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