List of usage examples for java.lang Double parseDouble
public static double parseDouble(String s) throws NumberFormatException
From source file:comp.web.core.DataUtil.java
public List<Product> getProds(String cat, String prod, String from, String to) { logger.log(Level.FINER, "get prods with filter {0} {1} {2} {3}", new Object[] { cat, prod, from, to }); if (StringUtils.isBlank(cat) && StringUtils.isBlank(prod) && StringUtils.isBlank(from) && StringUtils.isBlank(to)) { return Collections.emptyList(); }/*from w w w. j av a2 s . c om*/ String cat1 = StringUtils.stripToEmpty(cat) + "%"; String prod1 = StringUtils.stripToEmpty(prod) + "%"; double from1 = StringUtils.isNumeric(from) ? Double.parseDouble(from) : Double.MIN_VALUE; double to1 = StringUtils.isNumeric(to) ? Double.parseDouble(to) : Double.MAX_VALUE; EntityManager em = createEM(); // EntityTransaction tx = em.getTransaction(); // tx.begin(); List<Product> products = em.createNamedQuery("priceList", Product.class).setParameter("cat", cat1) .setParameter("prod", prod1).setParameter("from", from1).setParameter("to", to1).getResultList(); // tx.commit(); em.close(); logger.log(Level.FINER, "get prods result size {0}", products.size()); return products; }
From source file:de.qaware.chronix.solr.type.metric.functions.aggregations.Percentile.java
/** * Constructs a percentile aggregation/*from ww w. j ava 2s . c o m*/ * * @param args the function arguments, e.g. the percentile [0.0 ... 1.0] */ public Percentile(String[] args) { this.percentile = Double.parseDouble(args[0]); }
From source file:com.jaspersoft.jasperserver.war.cascade.handlers.converters.DoubleDataConverter.java
@Override public Double stringToValue(String rawData) { return StringUtils.isNotEmpty(rawData) ? Double.parseDouble(rawData.replace(",", ".")) : null; }
From source file:celeste.Celeste.java
public void pintarTrayectoriaPlaneta(int n_plat) { XYSeriesCollection coleccion = new XYSeriesCollection(); String name = planetas.get(n_plat)[0]; double a = Double.parseDouble(planetas.get(n_plat)[1]); double epsilon = Double.parseDouble(planetas.get(n_plat)[2]); double p = Double.parseDouble(planetas.get(n_plat)[3]); Planeta planeta = new Planeta(a, epsilon, p); XYSeries serie = planeta.generarPosiciones(); serie.setKey(name);/*from ww w . j av a2s . c o m*/ coleccion.addSeries(serie); generarGrafica(coleccion, false); }
From source file:com.vmware.example.lucene.loader.InstrumentPriceLineMapper.java
@Override public InstrumentPrice mapLine(String line, int lineNumber) throws Exception { StringTokenizer lineTokenizer = new StringTokenizer(line, ","); InstrumentPrice price = new InstrumentPrice(); price.setSymbol(lineTokenizer.nextToken()); price.setDate(formatter.parse(lineTokenizer.nextToken())); price.setHigh(Double.parseDouble(lineTokenizer.nextToken())); price.setLow(Double.parseDouble(lineTokenizer.nextToken())); price.setOpen(Double.parseDouble(lineTokenizer.nextToken())); price.setClose(Double.parseDouble(lineTokenizer.nextToken())); price.setVolume(Long.parseLong(lineTokenizer.nextToken())); return price; }
From source file:com.hurence.logisland.processor.TimeSeriesCsvLoader.java
/** * CSV reader that waits for a 2 columns csv files with or without a header. * If less than 2 columns ==> exception, otherwise, the 3rd and following columns are ignored * * @param in/* w w w. jav a 2 s. c om*/ * @param hasHeader * @param inputDatetimeFormat input date format * @return * @throws IOException * @throws IllegalArgumentException * @throws ArrayIndexOutOfBoundsException */ public static List<Record> load(Reader in, boolean hasHeader, DateTimeFormatter inputDatetimeFormat) throws IOException { List<Record> records = new ArrayList<>(); for (CSVRecord record : CSVFormat.DEFAULT.parse(in)) { try { if (!hasHeader) { StandardRecord event = new StandardRecord("sensors"); event.setField(TIMESTAMP_KEY, FieldType.LONG, inputDatetimeFormat.withZone(DateTimeZone.UTC) .parseDateTime(record.get(0)).getMillis()); event.setField(VALUE_KEY, FieldType.DOUBLE, Double.parseDouble(record.get(1))); records.add(event); } else { TIMESTAMP_KEY = record.get(0); VALUE_KEY = record.get(1); } hasHeader = false; } catch (Exception e) { logger.error("Parsing error " + e.getMessage()); throw new RuntimeException("parsing error", e); } } return records; }
From source file:com.canoo.webtest.util.ConversionUtil.java
/** * Convert a string value to a double. If the value is null, return the specified default value. * * @return parsed value. If value is null return default value. * @throws NumberFormatException// w ww .j ava 2 s . co m */ public static double convertToDouble(String value, double defaultValue) { if (value != null) { return Double.parseDouble(value); } return defaultValue; }
From source file:de.atomfrede.tools.evalutation.tools.plot.AbstractPlot.java
public double parseDoubleValue(String[] line, int type) { return Double.parseDouble(line[type].replace(",", ".")); }
From source file:gov.nih.nci.cabig.caaers.validation.fields.validators.SignValidator.java
@Override public boolean isValid(Object fieldValue) { if (fieldValue == null) return true; String s = fieldValue.toString(); try {//from www .java 2 s .c o m if (positive) return (NumberUtils.isNumber(s) && Double.parseDouble(s) >= 0); else return (NumberUtils.isNumber(s) && Double.parseDouble(s) < 0); } catch (NumberFormatException e) { return false; } }
From source file:Main.java
public static Object getNamedElemValue(Element parent, String elementName, Class basicType, Object defaultVal) { String val = getNamedElemValue(parent, elementName); if (val == null) { return defaultVal; }/*from ww w . j ava2 s . co m*/ try { if (Boolean.class.equals(basicType)) { return Boolean.parseBoolean(val); } else if (Integer.class.equals(basicType)) { return Integer.parseInt(val); } else if (Float.class.equals(basicType)) { return Float.parseFloat(val); } else if (Double.class.equals(basicType)) { return Double.parseDouble(val); } else return val; } catch (Exception e) { return defaultVal; } }