List of usage examples for java.lang Double parseDouble
public static double parseDouble(String s) throws NumberFormatException
From source file:com.qagen.osfe.core.utils.BeanPopulator.java
public static Object getValueAsType(String name, String value, String type, String format) { if ((value != null) && (value.trim().length() == 0)) { return null; }/*from w w w . j ava2 s. c om*/ if (type.equals(AttributeType.String.name())) { return value; } if (type.equals(AttributeType.Integer.name())) { return Integer.parseInt(value); } if (type.equals(AttributeType.Float.name())) { return Float.parseFloat(value); } if (type.equals(AttributeType.Double.name())) { return Double.parseDouble(value); } if (type.equals(AttributeType.Boolean.name())) { return Boolean.parseBoolean(value); } if (type.equals(AttributeType.Date.name())) { return getDate(name, value, format); } if (type.equals(AttributeType.Time.name())) { return getTime(name, value, format); } if (type.equals(AttributeType.Long.name())) { return Long.parseLong(value); } if (type.equals(AttributeType.Timestamp.name())) { return getTimestamp(name, value, format); } if (type.equals(AttributeType.Object.name())) { return Timestamp.valueOf(value); } final String message = "The value type, " + type + " is not a defined type. " + "You may need to extend the RowParser class and override the method, getValueAsType()."; throw new FeedErrorException(message); }
From source file:com.twosigma.beakerx.table.TableDisplayConverter.java
private static Object convertToNumber(Object value) { if (value instanceof String && NumberUtils.isNumber((String) value)) { return Double.parseDouble((String) value); } else {/*from w w w.j av a2 s. c o m*/ return value; } }
From source file:com.eryansky.common.web.struts2.converter.DoubleConverter.java
@Override public Object convertFromString(Map context, String[] values, Class toClass) { if (values != null && values.length > 0) { if (values[0].indexOf(',') != -1) { return Double.parseDouble(StringUtils.replace(values[0], ",", "")); } else {/*from ww w.j ava2 s. co m*/ return Double.parseDouble(values[0]); } } return null; }
From source file:com.gallatinsystems.common.util.JFreechartChartUtil.java
/** * generates a pie chart with the set of labels and values passed in (the labels and values * arrays must both be non-null and contain the same number of elements). The chart is returned * as a byte array representing the image. * /*from w w w. j a v a 2 s . com*/ * @param labels * @param values * @param title * @param width * @param height * @return - byte array containing the image, null if there is an error. */ public static byte[] getPieChart(List<String> labels, List<String> values, String title, int width, int height) { DefaultPieDataset pieDataset = new DefaultPieDataset(); for (int i = 0; i < labels.size(); i++) { pieDataset.setValue(labels.get(i) + " (" + values.get(i) + ")", Double.parseDouble(values.get(i))); } JFreeChart chart = ChartFactory.createPieChart(title, pieDataset, false, false, false); try { return ChartUtilities.encodeAsPNG(chart.createBufferedImage(width, height)); } catch (Exception e) { e.printStackTrace(System.err); return null; } }
From source file:it.polimi.proximityapi.jsonLogic.POIJsonParser.java
public static ArrayList<POI> parsePOIFile(String jsonString) { ArrayList<POI> poiList = new ArrayList<>(); JSONParser parser = new JSONParser(); JSONArray poiArray;//ww w . j ava2s . c o m try { poiArray = (JSONArray) parser.parse(jsonString); for (int i = 0; i < poiArray.size(); i++) { JSONObject jsonPOI = (JSONObject) poiArray.get(i); POI poi = new POI(); poi.setName((String) jsonPOI.get(JsonStrings.NAME)); poi.setLatitude(Double.parseDouble((String) jsonPOI.get(JsonStrings.LATITUDE))); poi.setLongitude(Double.parseDouble((String) jsonPOI.get(JsonStrings.LONGITUDE))); if (!jsonPOI.get(JsonStrings.RADIUS).equals("")) poi.setRadius(Float.parseFloat((String) jsonPOI.get(JsonStrings.RADIUS))); else { //Default radius set when it is not set in the corresponding JSON object poi.setRadius(TechnologyManager.BT_START_GEOFENCE_RADIUS); } poi.setBeaconUuid((String) jsonPOI.get(JsonStrings.BEACON_UUID)); poiList.add(poi); } } catch (ParseException e) { e.printStackTrace(); } return poiList; }
From source file:com.dsh105.nexus.util.StringUtil.java
/** * Tests if the given String is an Double * * @param string the String to be checked * @return true if Double//from ww w. j ava2s.c o m */ public static boolean isDouble(String string) { try { Double.parseDouble(string); } catch (NumberFormatException ex) { return false; } return true; }
From source file:Main.java
/** * @param colorNode// w w w . j a va 2 s . com * @return the alpha value */ public static String toAlphaValue(Node colorNode) { String value = "1"; if (colorNode == null || colorNode.getFirstChild() == null) { return value; } try {// FIXME no good to grab 1st child than node val String nodeVal = colorNode.getFirstChild().getNodeValue(); value = String.valueOf(Double.parseDouble(nodeVal) / 255d); } catch (Exception e) { e.printStackTrace(); } // don't care about number formating, just trim the string if (value.length() > 6) { value = value.substring(0, 5); } return value; }
From source file:com.dtstack.jlogstash.assembly.CmdLineParams.java
public static double getInputQueueCoefficient() { String number = line.getOptionValue("c"); double coefficient = StringUtils.isNotBlank(number) ? Double.parseDouble(number) : SystemProperty.getInputProportion(); logger.warn("input queue coefficient:{}", String.valueOf(coefficient)); return coefficient; }
From source file:Main.java
public static double parseDS(String s) { return s != null && s.length() != 0 ? Double.parseDouble(s.replace(',', '.')) : 0; }
From source file:com.zotoh.core.util.DataUte.java
/** * @param obj//from w w w . ja v a 2 s .c om * @return */ public static double toDouble(Object obj) { if (isNull(obj)) throw new RuntimeException("Null object conversion not allowed"); if (obj instanceof Double) { return (Double) obj; } else { return Double.parseDouble(obj.toString()); } }