|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.esri.arcgis.util.dataset.DoubleConversion
public class DoubleConversion
Provides simple utilities to convert between double and String.
To convert String to double, this class adds support for exponential format
over what is available within java.text.NumberFormat
.
To convert double to String, this class adds support for easily constructing a NumberFormat as well as setting fraction and integer precision parameters in a single method.
Constructor Summary | |
---|---|
DoubleConversion()
|
Method Summary | |
---|---|
static String |
doubleToString(boolean value)
Converts the given Boolean to String. |
static String |
doubleToString(double value)
Converts a double to String using the default Locale and standard NumberFormat. |
static String |
doubleToString(double value,
int maxFractionDigits,
int minFractionDigits,
int maxIntegerDigits,
int minIntegerDigits)
Converts a double to String using current Locale and specified fraction and integer lengths that are used in conjunction with a NumberFormat. |
static String |
doubleToString(double value,
int maxFractionDigits,
int minFractionDigits,
int maxIntegerDigits,
int minIntegerDigits,
Locale locale)
Converts a double to String using given Locale, fraction, and integer lengths that are used in conjunction with a NumberFormat. |
static String |
doubleToString(long value)
Converts a long to String |
static NumberFormat |
getFormat(int maxFractionDigits,
int minFractionDigits,
int maxIntegerDigits,
int minIntegerDigits,
Locale locale)
Constructs and returns a NumberFormat with given precision parameters and Locale. |
static NumberFormat |
getScientificFormat(NumberFormat base,
Locale locale)
Constructs and returns a NumberFormat that can be used for formatting decimal values into scientific notation. |
static NumberFormat |
getStandardFormat(Locale locale)
Constructs a NumberFormat for given locale, using the following parameters: maxFractionDigits = 20, minFractionDigits = 1, maxIntegerDigits = 20, minIntegerDigits = 1. |
static double |
stringToDouble(String value)
Converts a String to a double using the standard NumberFormat with current default Locale. |
static double |
stringToDouble(String value,
double defaultValue)
Converts a String to a double using the standard NumberFormat with current default Locale. |
static double |
stringToDouble(String value,
double defaultValue,
Locale locale)
Converts a String to a double using the standard NumberFormat with given Locale. |
static double |
stringToDouble(String value,
double defaultValue,
NumberFormat format)
Converts a String to a double using the given NumberFormat. |
static double |
stringToDouble(String value,
Locale locale)
Converts a String to a double using the standard NumberFormat with specified locale. |
static double |
stringToDouble(String value,
NumberFormat format)
Converts a String to a double using the specified NumberFormat. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DoubleConversion()
Method Detail |
---|
public static NumberFormat getFormat(int maxFractionDigits, int minFractionDigits, int maxIntegerDigits, int minIntegerDigits, Locale locale)
maxFractionDigits
- the maximum number of faction digitsminFractionDigits
- the minumum number of faction digitsmaxIntegerDigits
- the maximum number of integer digitsminIntegerDigits
- the minimum number of integer digitslocale
- the localepublic static NumberFormat getStandardFormat(Locale locale)
locale
- the locale
public static NumberFormat getScientificFormat(NumberFormat base, Locale locale)
The NumberFormat will have a pattern applied that is constructed
using the number of integer and fraction characters within the
given NumberFormat. It is expected that the base
format will be
used for regular number formatting, and the format constructed by this method will
be used for scientific notation when the base
format is
inappropriate (the number is to large or too small for the base format).
base
- the base number formatlocale
- the locale
public static String doubleToString(double value, int maxFractionDigits, int minFractionDigits, int maxIntegerDigits, int minIntegerDigits, Locale locale)
value
- the double to convertmaxFractionDigits
- the maximum number of fraction digitsminFractionDigits
- the minimum number of fraction digitsmaxIntegerDigits
- the maximum number of integer digitsminIntegerDigits
- the minimum number of integer digitslocale
- the locale
NumberFormat
public static String doubleToString(double value, int maxFractionDigits, int minFractionDigits, int maxIntegerDigits, int minIntegerDigits)
value
- the double to convertmaxFractionDigits
- the maximum number of fraction digitsminFractionDigits
- the minimum number of fraction digitsmaxIntegerDigits
- the maximum number of integer digitsminIntegerDigits
- the minimum number of integer digits
NumberFormat
public static String doubleToString(double value)
value
- the double to convert
DoubleConversion.doubleToString(double,int,int,int,int)
,
DoubleConversion.getStandardFormat(java.util.Locale)
public static String doubleToString(boolean value)
value
- the boolean to convert
public static String doubleToString(long value)
value
- the long to convert
public static double stringToDouble(String value, double defaultValue, NumberFormat format)
ParsingException
occurs.
value
- the String value to be converteddefaultValue
- the default value to use in case of parsing errorformat
- the NumberFormat to be used
public static double stringToDouble(String value, double defaultValue, Locale locale)
ParsingException
occurs.
value
- the String value to be converteddefaultValue
- the default value to use in case of parsing errorlocale
- the Locale to be used
public static double stringToDouble(String value)
ParsingException
occurs.
value
- the String value to be converted
public static double stringToDouble(String value, double defaultValue)
ParsingException
occurs.
value
- the String value to be converteddefaultValue
- the default value to use in case of parsing error
public static double stringToDouble(String value, Locale locale) throws ParseException
value
- the String value to be convertedlocale
- the Locale to be used when constructing standard format
ParseException
- if parse errors occurpublic static double stringToDouble(String value, NumberFormat format) throws ParseException
value
- the String value to be convertedformat
- the NumberFormat to be used
ParseException
- if parse errors occur
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |