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 String toString() 

Source Link

Document

Returns a string representation of this Double object.

Usage

From source file:de.iteratec.iteraplan.businesslogic.exchange.legacyExcel.importer.ExcelImportUtilities.java

private static String getNumericCellContentAsString(Cell cell, ProcessingLog processingLog) {
    // for numeric cells / dates we have to look at the cell format to tell if it's a date cell
    // If so, we retrieve the value as a date and convert it to ISO String notation

    if (HSSFDateUtil.isCellDateFormatted(cell)) {
        // is it a date-formatted number? then return the ISO-formatted date instead of the number
        Date cellDate = contentAsDate(cell);
        final SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
        return dateformatter.format(cellDate);
    }/*w  ww. ja  va  2  s .  co  m*/

    Double d = null;
    try {
        d = contentAsDouble(cell);
    } catch (NumberFormatException ex) {
        processingLog.warn("Cell [{0}] {1}; ignoring the value", getCellRef(cell), ex.getMessage());
    } catch (IllegalStateException e) {
        processingLog.warn("Cell [{0}] {1}; ignoring the value", getCellRef(cell), e.getMessage());
    }

    if (d != null) {
        // cut off *.0
        double i = d.doubleValue() - d.intValue();

        if (i == 0) {
            Integer j = Integer.valueOf(d.intValue());
            return j.toString();
        } else {
            return d.toString();
        }
    }
    return "";
}

From source file:models.dao.OldSensorReadingDaoImplementation.java

@Override
public boolean addReading(String deviceId, Long timeStamp, String sensorType, Double value) {
    final String SQL = "INSERT INTO CMU.CMU_SENSOR (DEVICEID, TIMESTAMP, SENSORTYPE, VALUE)" + "VALUES ('"
            + deviceId + "','" + timeStamp.toString() + "','" + sensorType + "','" + value.toString() + "')";
    try {//from   ww w .j a  va2s .  c om
        simpleJdbcTemplate.update(SQL);
    } catch (Exception e) {
        return false;
    }
    return true;
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindDoubleDefMaxValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindDoubleDefMaxValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }// ww  w  . j  a  va 2  s  .c o  m

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamDoubleDefObj) {
        Double maxValue = ((ICFBamDoubleDefObj) genDef).getOptionalMaxValue();
        if (maxValue == null) {
            ret = null;
        } else {
            ret = maxValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamDoubleDefObj");
    }

    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindDoubleDefMinValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindDoubleDefMinValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }//from  ww  w  . j  a  v  a2  s . c o m

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamDoubleDefObj) {
        Double minValue = ((ICFBamDoubleDefObj) genDef).getOptionalMinValue();
        if (minValue == null) {
            ret = null;
        } else {
            ret = minValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamDoubleDefObj");
    }

    return (ret);
}

From source file:experiment.ExperimentLogger.java

public void recordMean(double[] utils, int iter) {
    content.append("Total utility: ");
    int i = 0;/*w  w  w  . ja  va 2  s  .  c  o m*/
    //content.setLength(0);
    for (i = 0; i < utils.length; i++) {
        double n = utils[i];
        Double util = n / iter;
        content.append(util.toString() + "\t");
        //content.append("\t" + stateCount[i] + ret);
    }
    content.append(ret);
    //config.append(ret);
}

From source file:ml.shifu.shifu.util.JexlTest.java

@Test
public void testDouble() {
    Double a = Double.NaN;
    Double b = Double.valueOf(a.toString());
    Assert.assertEquals(a, b);
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindDoubleDefInitValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindDoubleDefInitValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }/*from  w  ww .  j av  a  2  s. c om*/

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamDoubleDefObj) {
        Double initValue = ((ICFBamDoubleDefObj) genDef).getOptionalInitValue();
        if (initValue == null) {
            ret = null;
        } else {
            ret = initValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamDoubleDefObj");
    }

    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindDoubleDefNullValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindDoubleDefNullValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }// w  w  w  .j a  va  2s  .c o  m

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamDoubleDefObj) {
        Double nullValue = ((ICFBamDoubleDefObj) genDef).getOptionalNullValue();
        if (nullValue == null) {
            ret = null;
        } else {
            ret = nullValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamDoubleDefObj");
    }

    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindDoubleDefDefaultValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindDoubleDefDefaultValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }// w  ww  . j a  v a 2  s  . c  o m

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamDoubleDefObj) {
        Double defaultValue = ((ICFBamDoubleDefObj) genDef).getOptionalDefaultValue();
        if (defaultValue == null) {
            ret = null;
        } else {
            ret = defaultValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamDoubleDefObj");
    }

    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindDoubleDefUnknownValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindDoubleDefUnknownValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }/*from w w  w  .ja v a 2 s  .  c  o m*/

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamDoubleDefObj) {
        Double unknownValue = ((ICFBamDoubleDefObj) genDef).getOptionalUnknownValue();
        if (unknownValue == null) {
            ret = null;
        } else {
            ret = unknownValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamDoubleDefObj");
    }

    return (ret);
}