In software programming, sometime you may want to convert a long integer or integer into hexadecimal string for viewing purpose or also as a text format to be stored in text file or database. The Java API itself does not have a class or function to convert a long into a fixed 16 characters hexadecimal string or an integer into fixed 8 characters hexadecimal string. The … [Read more...]
Java: Format integer into number of decimal places and performance
For certain reasons (e.g. precision issue), some programmer may store a float value (e.g. money) in integer variable. For example -12345678.90 is stored as -1234567890. To convert the integer value to number with number of decimal places is a problem. There are several way to do it. You can simply use the Java's String.format(), DecimalFormat or Float.toString(). Most of … [Read more...]