Java Hex Format FormatAs4CharHexa(int nValue)

Here you can find the source of FormatAs4CharHexa(int nValue)

Description

Format As Char Hexa

License

LGPL

Declaration

static public String FormatAs4CharHexa(int nValue) 

Method Source Code

//package com.java2s;
/*/*ww  w.  java 2  s.  c om*/
 * JLib - Publicitas Java library v1.2.0.
 *
 * Copyright (c) 2005, 2006, 2007, 2008, 2009 Publicitas SA.
 * Licensed under LGPL (LGPL-LICENSE.txt) license.
 */

public class Main {
    static public String FormatAs4CharHexa(int nValue) {
        String cs = "";
        char c;
        for (int n = 0; n < 4; n++) {
            int nChar = nValue % 16;
            nValue = nValue / 16;
            if (nChar <= 9)
                c = (char) ('0' + nChar);
            else
                c = (char) ('A' + nChar - 10);
            cs = c + cs;
        }
        return cs;
    }
}

Related

  1. formatAddress6(int[] hexRepresentation)
  2. FormatAs2CharHexa(byte byValue)
  3. formatAsHex(byte[] bytes)
  4. formatAsHex(long msgId)
  5. formatAsHexUppercase(long msgId)
  6. formatAsRawHex(int bitStringLength, String hex)