List of usage examples for java.lang Double parseDouble
public static double parseDouble(String s) throws NumberFormatException
From source file:Main.java
/** * parse value to double/*from w ww . j a va 2 s .c o m*/ */ public static double toDouble(String value) { return TextUtils.isEmpty(value) ? 0 : Double.parseDouble(value); }
From source file:Main.java
public static String getNormal(String txamt) { String str = txamt;// ww w. jav a 2s .c om if (str != null) { try { String sum = ""; int index = 0; char c = str.charAt(index); while (c == '0') { index++; c = str.charAt(index); } sum = str.substring(index); double i = Double.parseDouble(sum); i = i / 100; BigDecimal bg = new BigDecimal(i); double j = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); sum = "" + j; return sum; } catch (Exception e) { e.printStackTrace(); } } return null; }
From source file:Main.java
protected static final String encodingUTF8andSignPrefix(byte[] src, int srart, int length) throws Exception { byte[] b = new String(src, srart, length, "euc-kr").getBytes("utf-8"); String str = new String(b).trim(); str = str.substring(searchChar(str)); DecimalFormat f = new DecimalFormat("###,###,###"); f.setPositivePrefix("+"); f.setNegativePrefix("-"); return f.format(Double.parseDouble(str)); }
From source file:Main.java
public static Double[] getDataList(Node sampleNode) { if (sampleNode == null) return new Double[0]; List<Double> measureValues = new ArrayList<Double>(); Node n = sampleNode.getFirstChild(); while (n != null) { if (n.getNodeName().equalsIgnoreCase("data")) { String ms = n.getFirstChild().getNodeValue(); double mesVal = Double.parseDouble(ms); measureValues.add(new Double(mesVal)); }//www. j a v a2 s. c om n = n.getNextSibling(); } return measureValues.toArray(new Double[0]); }
From source file:Main.java
public static String formatMoney(String amount) { if (TextUtils.isEmpty(amount)) { return "0.00"; }//from w w w. j a v a2 s . com String result; try { double num = Double.parseDouble(amount); DecimalFormat formater = new DecimalFormat("###,##0.00"); result = formater.format(num / 100.0d); } catch (NumberFormatException e) { result = amount; } return result; }
From source file:Main.java
/** * Loads an optional double element value from a XML element *//* w ww . j a v a 2 s . c om*/ public static double getDoubleNode(Element element, String name) { Element child = getSingleElement(element, name); if (child == null) return 0.0; String value = child.getTextContent(); if (value == null) return 0.0; if (value.length() == 0) return 0.0; return Double.parseDouble(value); }
From source file:Main.java
public static double[] getVivaCurrentLocation(Context context) { String loc = getPreferences(context).getString(Viva_Current_Location, "0,0"); String[] locArray = loc.split(Pattern.quote(",")); return new double[] { Double.parseDouble(locArray[0]), Double.parseDouble(locArray[1]) }; }
From source file:Main.java
public static double parseDouble(String value, double defaultValue) { try {// w w w. ja v a 2s. c o m return Double.parseDouble(value); } catch (NumberFormatException nfe) { return defaultValue; } }
From source file:Main.java
public static Double convertDouble(String str) { double val = 0; try {//from ww w . j a v a2s. c o m val = Double.parseDouble(str); } catch (NumberFormatException ex) { } return new Double(val); }
From source file:Main.java
/** Helper method - gets a named element's value as a <I>double</I>. @param pElement The parent <I>Element</I>. @param strName Name of the element./*from www . jav a 2 s . c o m*/ @return Value of the element. */ public static double getElementDouble(Element pElement, String strName) throws ClassCastException, NumberFormatException { String strValue = getElementString(pElement, strName); if (null == strValue) return Double.NaN; return Double.parseDouble(strValue); }