Example usage for java.lang Integer toHexString

List of usage examples for java.lang Integer toHexString

Introduction

In this page you can find the example usage for java.lang Integer toHexString.

Prototype

public static String toHexString(int i) 

Source Link

Document

Returns a string representation of the integer argument as an unsigned integer in base 16.

Usage

From source file:Main.java

public static String getHexForColor(int c) {
    return "#" + Integer.toHexString((c & 0xffffff) | 0x1000000).substring(1);
}

From source file:Main.java

public static int getEdgeColor(int color) {
    String reflectColorStr = Integer.toHexString(color);
    String rgbStr = reflectColorStr.substring(2);
    return Color.parseColor("#00" + rgbStr);
}

From source file:Main.java

public static String parseColorFromInt(int colorInt) {
    return Integer.toHexString(colorInt);
}

From source file:Main.java

public static String decToHex(int dec) {
    String tempString = Integer.toHexString(dec);
    return tempString.substring(2);
}

From source file:Main.java

public static String byteToHex(byte b) {
    int i = b & 0xFF;
    return Integer.toHexString(i);
}

From source file:Main.java

public static String int2HaxString(int i) {
    String hex = Integer.toHexString(i);
    if (hex.length() == 1) {
        hex = "0" + hex;
    }/* www.j  a v a2  s.  c o  m*/
    return hex;
}

From source file:Main.java

public static String algorismToHEXString(int algorism) {
    String result = "";
    result = Integer.toHexString(algorism);

    if (result.length() % 2 == 1) {
        result = "0" + result;

    }// ww w .  ja  v a  2  s  .c  o  m
    result = result.toUpperCase();

    return result;
}

From source file:Main.java

public static String decimalIntToHexString(int decimal) {
    String str = "0";
    try {//  ww  w. j a v a 2s .  c o m
        str = Integer.toHexString(decimal);
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
    return str;
}

From source file:Main.java

public static String toHexColor(int rgb) {
    final String s = "00000" + Integer.toHexString(rgb);
    return "#" + s.substring(s.length() - 6);
}

From source file:Main.java

public static int getDataLength(byte byte1, byte byte2) {
    int len16 = 0;
    String hex = Integer.toHexString(byte1 & 0xFF);
    if (hex.length() == 1) {
        hex = '0' + hex;
    }/* w  ww . j  a  v a2  s  .c  om*/
    len16 = Integer.valueOf(hex, 16);
    int len17 = 0;
    String hex1 = Integer.toHexString(byte2 & 0xFF);
    if (hex1.length() == 1) {
        hex1 = '0' + hex1;
    }
    len17 = Integer.valueOf(hex1, 16);
    int pktLen = len16 * 256 + len17;
    return pktLen;
}