Example usage for java.lang Double toString

List of usage examples for java.lang Double toString

Introduction

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

Prototype

public static String toString(double d) 

Source Link

Document

Returns a string representation of the double argument.

Usage

From source file:com.android.projecte.townportal.WeatherInfo.java

public String convertSpeed(Double mps) {
    Double res;//from  w  w  w  .j  av a2  s . c  om
    String mph;
    res = mps * 60 * 60 * 100 / 2.54 / 12 / 5280;
    mph = Double.toString(Math.round(res));
    return mph;
}

From source file:com.fengduo.bee.commons.util.NumberParser.java

public static double mul(double a, double b) {
    BigDecimal b1 = new BigDecimal(Double.toString(a));
    BigDecimal b2 = new BigDecimal(Double.toString(b));
    return b1.multiply(b2).doubleValue();
}

From source file:io.wcm.sling.commons.request.RequestParamTest.java

@SuppressWarnings("unused")
protected Map<String, Object> getParamMap() throws UnsupportedEncodingException {
    return ImmutableMap.<String, Object>builder().put(STRING_PARAM, new String[] { STRING_VALUE })
            .put(MULTI_STRING_PARAM, MULTI_STRING_VALUE)
            .put(INTEGER_PARAM, new String[] { Integer.toString(INTEGER_VALUE) })
            .put(LONG_PARAM, new String[] { Long.toString(LONG_VALUE) })
            .put(FLOAT_PARAM, new String[] { Float.toString(FLOAT_VALUE) })
            .put(DOUBLE_PARAM, new String[] { Double.toString(DOUBLE_VALUE) })
            .put(BOOLEAN_PARAM, new String[] { Boolean.toString(BOOLEAN_VALUE) })
            .put(ENUM_PARAM, new String[] { ENUM_VALUE.name() })
            .put(RequestParam.PARAMETER_FORMENCODING, new String[] { CharEncoding.UTF_8 }).build();
}

From source file:dk.netarkivet.harvester.harvesting.frontier.FrontierReportCsvExport.java

private static String getDisplayValue(double val) {
    if (Double.MIN_VALUE == val) {
        return FrontierReportLine.EMPTY_VALUE_TOKEN;
    }/*  w w  w  .j a  v a2 s.  co m*/
    return (Math.rint(val) == val ? Integer.toString((int) val) : "" + Double.toString(val));
}

From source file:com.church.tools.ChartTools.java

/**
 * Generate pie chart.//  w  ww  .j  a v a2s. com
 * 
 * @param title the title
 * @param values the values
 * @param captions the captions
 * @param width the width
 * @param height the height
 * @param color the color
 * 
 * @return the buffered image
 */
public static BufferedImage GeneratePieChart(String title, double[] values, String[] captions, int width,
        int height, Color color) {
    BufferedImage bufferedImage = null;
    DefaultPieDataset pieDataset = new DefaultPieDataset();
    Hashtable<String, String> ht = new Hashtable<String, String>();
    for (int i = 0; i < values.length; i++)
        ht.put(captions[i], Double.toString(values[i]));

    Enumeration<String> enu = ht.keys();
    int i = 0;
    while (enu.hasMoreElements()) {
        String str = (String) enu.nextElement();
        pieDataset.setValue(str, new Double(Double.parseDouble((String) ht.get(str))));
        i++;
    }

    JFreeChart chart = ChartFactory.createPieChart(title, pieDataset, false, false, false);
    chart.setBackgroundPaint(color);
    bufferedImage = chart.createBufferedImage(width, height);
    return bufferedImage;
}

From source file:com.addthis.bundle.value.DefaultDouble.java

@Override
public ValueString asString() throws ValueTranslationException {
    return ValueFactory.create(Double.toString(value));
}

From source file:playground.dgrether.analysis.charts.DgModalSplitQuantilesChart.java

private void calculateData() {
    List<DgAnalysisPopulation> quantiles = this.ana.getQuantiles(this.nQuantiles,
            new DgPersonDataIncomeComparator());
    List<String> labels = new ArrayList<String>();

    for (DgAnalysisPopulation p : quantiles) {
        p.calculateMinMaxIncome();//from   www .ja  v a  2  s .  co m
        double carPlans = p.calculateNumberOfCarPlans(runId);
        int groupSize = p.getPersonData().size();
        double carFraction = carPlans / groupSize * 100.0;
        double ptFraction = (groupSize - carPlans) / groupSize * 100;
        String title = Double.toString(p.getMaxIncome());
        title = title.substring(0, title.indexOf("."));
        this.dataset.addValue(carFraction, "car", title);
        this.dataset.addValue(ptFraction, "non-car", title);
    }
}

From source file:org.openiot.gsn.http.rest.PushDelivery.java

private boolean sendData(String xml) {
    try {/*www . ja  va 2  s  . co m*/
        ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
        postParameters
                .add(new BasicNameValuePair(PushDelivery.NOTIFICATION_ID_KEY, Double.toString(notificationId)));
        postParameters.add(new BasicNameValuePair(PushDelivery.DATA, xml));

        httpPut.setEntity(new UrlEncodedFormEntity(postParameters, HTTP.UTF_8));

        HttpResponse response = httpclient.execute(httpPut);

        int statusCode = response.getStatusLine().getStatusCode();
        response.getEntity().getContent().close(); // releasing the connection to the http client's pool
        if (statusCode != RestStreamHanlder.SUCCESS_200) {
            return false;
        }
        return true;
    } catch (Exception e) {
        logger.warn(e.getMessage(), e);
        return false;
    }

}

From source file:com.aurel.track.lucene.util.poi.XLSTextStripper.java

public XLSTextStripper(FileInputStream fis, String fileExtension) {
    try {//from www .  jav  a  2 s .  co  m
        StringBuffer sb = new StringBuffer();
        Workbook workbook = null;
        if (LuceneFileExtractor.INDEXABLE_EXTENSIONS.XLS.equalsIgnoreCase(fileExtension)) {
            workbook = new HSSFWorkbook(fis);
        } else {
            if (LuceneFileExtractor.INDEXABLE_EXTENSIONS.XLSX.equalsIgnoreCase(fileExtension)) {
                workbook = new XSSFWorkbook(fis);
            }
        }
        if (workbook != null) {
            int numOfSheets = workbook.getNumberOfSheets();
            for (int i = 0; i < numOfSheets; i++) {
                Sheet sheet = workbook.getSheetAt(i);
                Iterator<Row> rowIterator = sheet.rowIterator();
                while (rowIterator.hasNext()) {
                    Row row = rowIterator.next();
                    Iterator<Cell> cellIterator = row.cellIterator();
                    while (cellIterator.hasNext()) {
                        Cell cell = cellIterator.next();
                        String cellStringValue = null;
                        if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
                            boolean booleanValue = cell.getBooleanCellValue();
                            cellStringValue = Boolean.toString(booleanValue);
                        } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
                            double doubleValue = cell.getNumericCellValue();
                            cellStringValue = Double.toString(doubleValue);
                        } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
                            cellStringValue = cell.getStringCellValue();
                        }
                        if (cellStringValue != null) {
                            sb.append(cellStringValue);
                            sb.append("\t");
                        }
                    }
                    sb.append("\n");
                }
            }
        }
        _text = sb.toString();
    } catch (Exception e) {
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    }
}