Java examples for java.lang:Hex
get Two Digit Hex String
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int integer = 2; System.out.println(getTwoDigitHexString(integer)); }/*from w w w . jav a 2s . c o m*/ private static String getTwoDigitHexString(int integer) { StringBuilder sb = new StringBuilder(); sb.append(Integer.toHexString(integer)); if (sb.length() < 2) { sb.insert(0, '0'); // pad with leading zero if needed } return sb.toString(); } }