List of utility methods to do Decimal Format
Double | randomGenLat(Double latstart, Double latend) random Gen Lat Random ran = new Random(); double latdis = latend - latstart; return Double.parseDouble(df.format(ran.nextDouble() * latdis + latstart)); |
void | randomGenLngLat(Double lngstart, Double lngend, Double latstart, Double latend) random Gen Lng Lat Random ran = new Random(); Double lngdis = lngend - lngstart; double latdis = latend - latstart; int count = 0; while (count < 200) { count++; Double d1 = Double.parseDouble(df.format(ran.nextDouble() * lngdis + lngstart)); Double d2 = Double.parseDouble(df.format(ran.nextDouble() * latdis + latstart)); ... |
double | readThisDouble(final String value) read This Double double res; final String trimmed = value.trim(); if (trimmed.toUpperCase().equals("NAN")) res = 0; else { try { res = shortFormat.parse(trimmed).doubleValue(); } catch (final ParseException e) { ... |
String | renderDouble(double value, int precision) render Double return renderDouble(value, precision, ','); |
String | replaceCommaByPoint(String doubleString, 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. DecimalFormatSymbols symb = new DecimalFormatSymbols(loc); if (symb.getDecimalSeparator() == ',') { if (doubleString.indexOf(',') >= 0 && doubleString.indexOf(',') == doubleString.lastIndexOf(',') && doubleString.indexOf('.') == -1) { return doubleString.replace(',', '.'); return doubleString; ... |
String | sanitizeDouble(String value) Normalizes the decimal separator for the user's locale. value = value.replaceAll("[^0-9,\\.]", ""); final char separator = new DecimalFormatSymbols().getDecimalSeparator(); final char usedSeparator = separator == '.' ? ',' : '.'; value = value.replace(usedSeparator, separator); try { Double.parseDouble(value); } catch (final Exception e) { value = value.replace(separator, usedSeparator); ... |
String | singleDecimalDigit(double d) single Decimal Digit return new DecimalFormat("#.#").format(d); |
Double | string2Double(String s) string Double return mDecFmt.parse(s).doubleValue();
|
double | strParaDouble(String s, double valorPadrao) str Para Double try { return Double.parseDouble(s.trim()); } catch (Exception ex) { return valorPadrao; |
double | to3DP(double number) to DP return Double.valueOf(FORMAT.format(number));
|