List of usage examples for java.lang Double parseDouble
public static double parseDouble(String s) throws NumberFormatException
From source file:net.pickapack.util.StorageUnitHelper.java
/** * Convert the specified display size to the byte count. * * @param displaySize the display size//from w ww.jav a 2 s.com * @return the byte count corresponding to the specified display size */ public static long displaySizeToByteCount(String displaySize) { String[] parts = displaySize.split(" "); if (parts.length == 2) { double scale = Double.parseDouble(parts[0]); String unit = parts[1]; if (unit.equals("KB")) { return (long) (scale * FileUtils.ONE_KB); } else if (unit.equals("MB")) { return (long) (scale * FileUtils.ONE_MB); } else if (unit.equals("GB")) { return (long) (scale * FileUtils.ONE_GB); } else if (unit.equals("TB")) { return (long) (scale * FileUtils.ONE_TB); } else if (unit.equals("PB")) { return (long) (scale * FileUtils.ONE_PB); } else if (unit.equals("EB")) { return (long) (scale * FileUtils.ONE_EB); } } throw new IllegalArgumentException(); }
From source file:ListMoviesXML.java
private static Movie getMovie(Element e) { String yearString = e.getAttribute("year"); int year = Integer.parseInt(yearString); Element tElement = (Element) e.getFirstChild(); String title = getTextValue(tElement).trim(); Element pElement = (Element) tElement.getNextSibling(); String pString = getTextValue(pElement).trim(); double price = Double.parseDouble(pString); return new Movie(title, year, price); }
From source file:com.hangum.tadpole.sql.query.TadpoleSystemChecker.java
/** * ? ? ? . /* w w w . j a v a 2 s .c o m*/ * * @return */ public static void checker() throws Exception { double dblJavaVersion = Double.parseDouble(JAVA_VERSION.substring(0, 3)); // mac ? jvm 1.7 ?? ? . if (isMac()) { if (dblJavaVersion < 1.7d) { throw new Exception(String.format(Messages.TadpoleSystemChecker_2, "1.7.x")); //$NON-NLS-2$ } // ?? 1.6 ??? . } else { if (dblJavaVersion < 1.6d) { throw new Exception(String.format(Messages.TadpoleSystemChecker_2, "1.6.x")); //$NON-NLS-2$ } } }
From source file:Main.java
public static double getArgAttr(final Element node, final String strName, final String strAttrName, final double dDefaultValue) { final String strValue = getArgAttr(node, strName, strAttrName); if (strValue == null) { return dDefaultValue; }/* w w w . j a v a 2 s . c o m*/ return Double.parseDouble(strValue); }
From source file:autoancillarieslimited.parser.ParserUtil.java
public static Item parserItem(String dataJson) { try {/* w w w. ja v a 2s .c o m*/ Item i = new Item(); JSONParser parser = new JSONParser(); Object obj = parser.parse(dataJson); JSONObject jsonObject = (JSONObject) obj; int id = Integer.parseInt((String) jsonObject.get("P0")); String name = (String) jsonObject.get("P1"); String description = (String) jsonObject.get("P3"); int category = Integer.parseInt((String) jsonObject.get("P2")); double price = Double.parseDouble((String) jsonObject.get("P4")); String images = (String) jsonObject.get("P6"); // String imagesData i.setId(id); i.setName(name); i.setDescription(description); i.setPrice(price); i.setDate_Created(new Date()); TypeItem typeItemByID = ProductDAO.getInstance().getTypeItemByID(category); i.setTypeItem(typeItemByID); i.setType_ID(category); i.setImages(images); return i; } catch (Exception ex) { return null; } }
From source file:Main.java
public static long toTime(String expr) { Pattern p = Pattern.compile("(-?)([0-9][0-9]):([0-9][0-9]):([0-9][0-9])([\\.:][0-9][0-9]?[0-9]?)?"); Matcher m = p.matcher(expr);//www . j a va 2s .c o m if (m.matches()) { String minus = m.group(1); String hours = m.group(2); String minutes = m.group(3); String seconds = m.group(4); String fraction = m.group(5); if (fraction == null) { fraction = ".000"; } fraction = fraction.replace(":", "."); long ms = Long.parseLong(hours) * 60 * 60 * 1000; ms += Long.parseLong(minutes) * 60 * 1000; ms += Long.parseLong(seconds) * 1000; if (fraction.contains(":")) { ms += Double.parseDouble("0" + fraction.replace(":", ".")) * 40 * 1000; // 40ms == 25fps - simplifying assumption should be ok for here } else { ms += Double.parseDouble("0" + fraction) * 1000; } return ms * ("-".equals(minus) ? -1 : 1); } else { throw new RuntimeException("Cannot match '" + expr + "' to time expression"); } }
From source file:com.voterData.graph.Graph.java
public static JFreeChart getPopulationDistChart(ArrayList<VoterDetails> voterDetList) { DefaultPieDataset dataset = new DefaultPieDataset(); for (VoterDetails voterDetObj : voterDetList) { dataset.setValue(voterDetObj.getRes_city_desc(), Double.parseDouble(voterDetObj.getVoter_reg_num())); }/*from w w w . j a v a 2 s . c o m*/ boolean legend = true; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createPieChart("Population Distribution of Mecklenburg County", dataset, legend, tooltips, urls); //chart.setBorderPaint(Color.GREEN); //chart.setBorderStroke(new BasicStroke(5.0f)); //chart.setBorderVisible(true); /* DefaultCategoryDataset bardataset = new DefaultCategoryDataset(); for(VoterDetails voterDetObj : voterDetList){ bardataset.setValue(Double.parseDouble(voterDetObj.getVoter_reg_num()), "Population(%)", voterDetObj.getRes_city_desc()); } JFreeChart barchart = ChartFactory.createBarChart3D( "Population-Cities", //Title "Cities in Mecklenburg County", // X-axis Label "Population(%)", // Y-axis Label bardataset, // Dataset PlotOrientation.VERTICAL, //Plot orientation false, // Show legend true, // Use tooltips false // Generate URLs ); */ return chart; }
From source file:com.andrious.btc.data.jsonUtils.java
public static double lastPrice(String url) { double lastPrice; try {// ww w . j a v a 2s . c o m lastPrice = Double.parseDouble(findKeyValue(getJSONj(url), "last")); } catch (Exception ex) { lastPrice = 0.0; } return lastPrice; }
From source file:main.java.entry.ReadConfig.java
public static void readArgs(String[] args) { Global.wrl = args[0];//from w w w . j a v a2 s. co m Global.LOGGER.info("Workload type: " + Global.wrl); Global.scaleFactor = Double.parseDouble(args[1]); Global.LOGGER.info("'" + Global.wrl + "' Workload Scale Factor: " + Global.scaleFactor); Global.repeatedRuns = Integer.parseInt(args[2]); Global.LOGGER.info("Targeted number of repeated runs: " + Global.repeatedRuns); // Setting directory name and structure according to OS if (Utility.isWindows()) { Global.dir_sep = "\\"; Global.wrl_dir = System.getProperty("user.dir") + "\\workload" + "\\" + Global.wrl + "\\"; Global.metis_dir = System.getProperty("user.dir") + "\\metis\\win\\"; Global.part_dir = System.getProperty("user.dir") + "\\part\\"; Global.mining_dir = System.getProperty("user.dir") + "\\mining\\"; Global.metric_dir = System.getProperty("user.dir") + "\\metric\\"; Global.metis_hgr_exec = "khmetis.exe"; Global.metis_gr_exec = "gpmetis.exe"; } else if (Utility.isUnix()) { Global.dir_sep = "/"; Global.wrl_dir = System.getProperty("user.dir") + "/workload" + "/" + Global.wrl + "/"; Global.metis_dir = System.getProperty("user.dir") + "/metis/unix/"; Global.part_dir = System.getProperty("user.dir") + "/part/"; Global.mining_dir = System.getProperty("user.dir") + "/mining/"; Global.metric_dir = System.getProperty("user.dir") + "/metric/"; Global.metis_hgr_exec = "khmetis"; Global.metis_gr_exec = "gpmetis"; } else if (Utility.isOSX()) { Global.dir_sep = "/"; Global.wrl_dir = System.getProperty("user.dir") + "/workload" + "/" + Global.wrl + "/"; Global.metis_dir = System.getProperty("user.dir") + "/metis/osx/"; Global.part_dir = System.getProperty("user.dir") + "/part/"; Global.mining_dir = System.getProperty("user.dir") + "/mining/"; Global.metric_dir = System.getProperty("user.dir") + "/metric/"; Global.metis_hgr_exec = "khmetis"; Global.metis_gr_exec = "gpmetis"; } else { Global.LOGGER.error("Your OS is not supported !!"); } }
From source file:Main.java
public static double getDoubleAttribute(Node n, String s) { return Double.parseDouble(getAttribute(n, s)); }