Here you can find the source of formatText(String value, boolean showAsHexFlag)
Parameter | Description |
---|---|
value | the string to format |
showAsHexFlag | the boolean flag that determines wether to display a number as hex |
public static String formatText(String value, boolean showAsHexFlag)
//package com.java2s; // The JavaPOS Config/Loader (aka JCL) is now under the CPL license, which public class Main { /**//from ww w . j ava2 s. c om * reads an String representation of an Integer, if the showAsHexFlag is set, it converts it to hex * to a hex string representation for display * @param value the string to format * @param showAsHexFlag the boolean flag that determines wether to display a number as hex * @return a String to be displayed in the text field */ public static String formatText(String value, boolean showAsHexFlag) { try { int numberToCheck = Integer.parseInt(value); if (showAsHexFlag) { StringBuffer buffer = new StringBuffer(); buffer.append("0x"); buffer.append(Integer.toHexString(numberToCheck)); value = buffer.toString(); } } catch (NumberFormatException nfe) { } return value; } }