Example usage for java.lang Double parseDouble

List of usage examples for java.lang Double parseDouble

Introduction

In this page you can find the example usage for java.lang Double parseDouble.

Prototype

public static double parseDouble(String s) throws NumberFormatException 

Source Link

Document

Returns a new double initialized to the value represented by the specified String , as performed by the valueOf method of class Double .

Usage

From source file:de.qaware.chronix.solr.type.metric.functions.transformation.Subtract.java

/**
 * Constructs the subtract transformation.
 * The value is subtracted from each time series value
 *
 * @param value the value that is subtracted
 *///from w  ww. j  a  va2  s. co  m
public Subtract(String[] args) {
    this.value = Double.parseDouble(args[0]);
}

From source file:fr.norad.visuwall.plugin.jenkins.JenkinsVersionPage.java

private void addWarnings(SoftwareId softwareInfo, String strVersion) {
    String cleanedVersion = StringUtils.remove(strVersion, ".");
    if (isNumeric(cleanedVersion)) {
        double version = Double.parseDouble(strVersion);
        if (version < 1.405) {
            addWarningForVersionBefore1405(softwareInfo);
        }/*w w  w  .j a v  a2 s . co  m*/
    }
}

From source file:eu.scape_project.planning.xml.plan.OrdinalTransformerMappingFactory.java

@Override
public TargetValueObject createObject(Attributes arg0) throws Exception {
    TargetValueObject o = new TargetValueObject();
    o.setValue(Double.parseDouble(arg0.getValue("target")));
    return o;/*from   w  w w . ja v  a 2s.  co m*/
}

From source file:com.redsqirl.useful.NumberConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {

    if (value == null) {
        return null;
    }//from   w w w .j  a  v a  2s .  c  om

    if (value instanceof Float || value instanceof Double) {
        double dblValue = Double.parseDouble(value.toString());
        if (dblValue - ((int) dblValue) > 0) {
            if (dblValue > 10E5 || dblValue - ((int) dblValue) < 10E-3) {
                return String.format("%.2E", dblValue);
            } else {
                return String.format("%.2f", dblValue);
            }
        }
    }

    return value.toString();
}

From source file:com.bdnc.ecommercebdnc.command.CadastraProduto.java

@Override
public void execute(HttpServletRequest request, HttpServletResponse response) {

    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
    if (isMultipart) {
        FileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload(factory);
        List<FileItem> items = null;
        try {/*from  w w w  .j a  v  a 2  s .com*/
            items = (List<FileItem>) upload.parseRequest(request);

            Produto produto = new Produto();
            produto.setFoto(items.get(0).get());
            produto.setDescricao(items.get(1).getString("UTF-8"));
            produto.setValor(Double.parseDouble(items.get(2).getString("UTF-8")));

            LojaService lojaService = new LojaService();
            lojaService.salvarProduto(produto);

            request.getSession().setAttribute("produtos", lojaService.listarProdutos());

            RequestDispatcher dispather = request.getRequestDispatcher("cadastroproduto.jsp");
            dispather.forward(request, response);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

From source file:com.charts.IntradayChart.java

public IntradayChart(YStockQuote currentStock) {

    TimeSeries series = new TimeSeries(currentStock.get_name());
    ArrayList<String> fiveDayData = currentStock.get_one_day_data();
    int length = fiveDayData.size();
    for (int i = 17; i < length; i++) {
        String[] data = fiveDayData.get(i).split(",");
        Date time = new Date((long) Integer.parseInt(data[0]) * 1000);
        DateFormat df = new SimpleDateFormat("MM-dd-yyyy-h-m");
        series.addOrUpdate(new Minute(time), Double.parseDouble(data[1]));
    }//  w  ww  .java  2  s.c o  m
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);
    JFreeChart chart = ChartFactory.createTimeSeriesChart(
            currentStock.get_name() + "(" + currentStock.get_symbol() + ")" + " Intraday", "Date", "Price",
            dataset, true, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    ValueAxis yAxis = (ValueAxis) plot.getRangeAxis();
    DateAxis xAxis = (DateAxis) plot.getDomainAxis();
    xAxis.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());
    xAxis.setDateFormatOverride(new SimpleDateFormat("h:m a"));
    xAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    //xAxis.setVerticalTickLabels(true);
    chartPanel = new ChartPanel(chart);
    chart.setBackgroundPaint(chartPanel.getBackground());
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    chartPanel.setVisible(true);
    chartPanel.revalidate();
    chartPanel.repaint();
}

From source file:com.hro.museapp.map.MarkerGenerator.java

public static HashMap<String, MarkerOptions> addMarkers(int type) {
    switch (type) {
    case PlacesLoader.TYPE_ALL:
        places = PlacesLoader.getPlaces();
        break;//from  w  w  w . j av a2  s  .  c o m
    case PlacesLoader.TYPE_SEARCH:
        places = PlacesLoader.getSearchResults();
        break;
    case PlacesLoader.TYPE_NEARBY:
        places = PlacesLoader.getNearbyResults();
        break;
    case PlacesLoader.TYPE_SINGLE:
        places = PlacesLoader.getSinglePlace();
        break;
    }

    mapPlaceToId = new HashMap<String, MarkerOptions>();
    try {
        for (int i = 0; i < places.length(); i++) {
            JSONObject c = places.getJSONObject(i);
            String title = c.getString(TAG_NAME);
            String lat = c.getString(TAG_LAT);
            String lon = c.getString(TAG_LONG);
            String mid = c.getString(TAG_MID);
            String cat = c.getString(TAG_CAT);
            LatLng loc = new LatLng(0, 0);
            try {
                loc = new LatLng(Double.parseDouble(lat), Double.parseDouble(lon));
            } catch (NumberFormatException nfe) {
                continue;
            }
            //mapPlaceToId.put(title, mid);
            /*Marker m = map
                  .addMarker(new MarkerOptions()
                .position(loc)
                .title(title)
                .icon(BitmapDescriptorFactory
                      .defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
            m.setData(mid);*/

            MarkerOptions m = new MarkerOptions().position(loc).title(title);

            if (cat.equals("Monument")) {
                m.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
            } else {
                m.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
            }
            mapPlaceToId.put(mid, m);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return mapPlaceToId;
}

From source file:model.Times.java

protected void parseValue(final String value) {
    try {/*  ww w .  j ava2  s .co  m*/
        setUserTime(Double.parseDouble(StringUtils.substringBetween(value, "user=", " ")));
        setSysTime(Double.parseDouble(StringUtils.substringBetween(value, "sys=", ",")));
        setRealTime(Double.parseDouble(StringUtils.substringBetween(value, "real=", " ")));
        LOG.info("Successfully parsed Times: " + this);
    } catch (final Exception ex) {
        LOG.error("Error parsing TIMES: ", ex);
    }
}

From source file:ml.shifu.core.di.builtin.binning.MunroPatBinning.java

@Override
public void addData(String val) {
    String fval = StringUtils.trimToEmpty(val);
    try {//from   w  w  w .j  a  v a2  s.com
        Double dval = Double.parseDouble(fval);
        estimator.add(dval);
    } catch (NumberFormatException e) {
        super.incInvalidValCnt();
    }
}

From source file:edu.illinois.cs.cogcomp.utils.Utils.java

/**
 * This reads a file in the ngram-format
 * http://www.speech.sri.com/projects/srilm/manpages/ngram-format.5.html
 *
 * and populates the languagemodel datastructure.
 *
 * @param fname//from  w w w.  ja v a  2  s . c o m
 * @return
 * @throws FileNotFoundException
 */
public static HashMap<String, Double> readSRILM(String fname) throws FileNotFoundException {
    List<String> lines = LineIO.read(fname);

    HashMap<String, Double> out = new HashMap<>();

    for (String line : lines) {

        if (line.trim().length() == 0 || line.startsWith("\\") || line.contains("ngram")) {
            // do nothing.
        } else {
            String[] sline = line.trim().split("\t");
            // important because of the log probabilities
            Double v = Math.exp(Double.parseDouble(sline[0]));
            String ngram = sline[1];

            String[] chars = ngram.split(" ");

            out.put(StringUtils.join(chars, ""), v);
        }
    }

    return out;
}