com.ibm.commons.util
Class Converter

java.lang.Object
  extended by com.ibm.commons.util.Converter

public final class Converter
extends java.lang.Object

Some data converter utilities.


Constructor Summary
Converter()
           
 
Method Summary
static java.lang.String formatBoolean(boolean value)
           
static java.lang.String formatBoolean(boolean value, java.util.Locale locale)
           
static java.lang.String formatDecimal(double d)
           
static java.lang.String formatDecimal(double d, java.util.Locale locale)
           
static java.lang.String formatDecimal(double d, java.lang.String format)
           
static java.lang.String formatDecimal(double d, java.lang.String format, java.lang.String emptyFormat)
           
static java.lang.String formatDecimal(double d, java.lang.String format, java.lang.String emptyFormat, java.util.Locale loc)
           
static java.lang.String formatInteger(long l)
           
static java.lang.String formatInteger(long l, java.util.Locale locale)
           
static java.lang.String formatInteger(long l, java.lang.String format)
           
static java.lang.String formatInteger(long l, java.lang.String format, java.lang.String emptyFormat)
           
static java.lang.String formatInteger(long l, java.lang.String format, java.lang.String emptyFormat, java.util.Locale loc)
           
static char getDecimalSeparator(java.util.Locale loc)
          Returns the decimal separator in this locale.
static char getGroupingSeparator(java.util.Locale loc)
          Returns the grouping separator (to separate every 3 digits in integer part of a number) in this locale.
static java.util.Locale getJVMLocale()
          Returns the default locale of the JVM.
static java.util.TimeZone getJVMTimeZone()
          Returns the default time zone of the JVM.
static boolean parseBoolean(java.lang.String value)
           
static boolean parseBooleanLocale(java.lang.String value)
           
static boolean parseBooleanLocale(java.lang.String value, java.util.Locale locale)
           
static double parseDecimal(java.lang.String src)
           
static double parseDecimal(java.lang.String src, java.util.Locale loc)
           
static double parseFloatWithDecimalSeparatorTolerance(java.lang.String doubleString, java.util.Locale loc)
           
static long parseInteger(java.lang.String src)
           
static long parseInteger(java.lang.String src, java.util.Locale loc)
           
static java.lang.String removeThousandSeparator(java.lang.String doubleString, java.util.Locale loc)
          If a decimal number contains thousand separator (example : a coma in US), they are removed, so that the string can be correctly interpreted by Double.parseDouble
static java.lang.String replaceCommaByPoint(java.lang.String doubleString, java.util.Locale loc)
          If a decimal number contains a comma and no point, and if the given locale uses a comma for decimal separator, the comma is replaced by a point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Converter

public Converter()
Method Detail

getDecimalSeparator

public static char getDecimalSeparator(java.util.Locale loc)
Returns the decimal separator in this locale.


getGroupingSeparator

public static char getGroupingSeparator(java.util.Locale loc)
Returns the grouping separator (to separate every 3 digits in integer part of a number) in this locale.


getJVMLocale

public static java.util.Locale getJVMLocale()
Returns the default locale of the JVM.


getJVMTimeZone

public static java.util.TimeZone getJVMTimeZone()
Returns the default time zone of the JVM.


parseInteger

public static long parseInteger(java.lang.String src)

parseInteger

public static long parseInteger(java.lang.String src,
                                java.util.Locale loc)
                         throws java.text.ParseException
Throws:
java.text.ParseException

formatInteger

public static java.lang.String formatInteger(long l)

formatInteger

public static java.lang.String formatInteger(long l,
                                             java.lang.String format)

formatInteger

public static java.lang.String formatInteger(long l,
                                             java.util.Locale locale)

formatInteger

public static java.lang.String formatInteger(long l,
                                             java.lang.String format,
                                             java.lang.String emptyFormat)

formatInteger

public static java.lang.String formatInteger(long l,
                                             java.lang.String format,
                                             java.lang.String emptyFormat,
                                             java.util.Locale loc)

parseDecimal

public static double parseDecimal(java.lang.String src)

parseDecimal

public static double parseDecimal(java.lang.String src,
                                  java.util.Locale loc)
                           throws java.text.ParseException
Throws:
java.text.ParseException

parseFloatWithDecimalSeparatorTolerance

public static double parseFloatWithDecimalSeparatorTolerance(java.lang.String doubleString,
                                                             java.util.Locale loc)

replaceCommaByPoint

public static java.lang.String replaceCommaByPoint(java.lang.String doubleString,
                                                   java.util.Locale loc)
If a decimal number contains a comma and no point, and if the given locale uses a comma for decimal separator, the comma is replaced by a point.


removeThousandSeparator

public static java.lang.String removeThousandSeparator(java.lang.String doubleString,
                                                       java.util.Locale loc)
If a decimal number contains thousand separator (example : a coma in US), they are removed, so that the string can be correctly interpreted by Double.parseDouble


formatDecimal

public static java.lang.String formatDecimal(double d)

formatDecimal

public static java.lang.String formatDecimal(double d,
                                             java.util.Locale locale)

formatDecimal

public static java.lang.String formatDecimal(double d,
                                             java.lang.String format)

formatDecimal

public static java.lang.String formatDecimal(double d,
                                             java.lang.String format,
                                             java.lang.String emptyFormat)

formatDecimal

public static java.lang.String formatDecimal(double d,
                                             java.lang.String format,
                                             java.lang.String emptyFormat,
                                             java.util.Locale loc)

formatBoolean

public static java.lang.String formatBoolean(boolean value)

formatBoolean

public static java.lang.String formatBoolean(boolean value,
                                             java.util.Locale locale)

parseBoolean

public static boolean parseBoolean(java.lang.String value)

parseBooleanLocale

public static boolean parseBooleanLocale(java.lang.String value)

parseBooleanLocale

public static boolean parseBooleanLocale(java.lang.String value,
                                         java.util.Locale locale)