Example usage for java.lang Double valueOf

List of usage examples for java.lang Double valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Double valueOf(double d) 

Source Link

Document

Returns a Double instance representing the specified double value.

Usage

From source file:com.marc.lastweek.extractionengine.adapters.EbayAdAdapter.java

public final static NewExternalClassifiedAdTO adapt(EbayAd ebayAd) {
    long categoryId = EBAY_PISOS_CATEGORIES_TO_LASTWEEK_CATEGORIES[ArrayUtils.indexOf(EBAY_PISOS_CATEGORIES,
            ebayAd.getCategory().trim())];
    Double price = null;/*from   ww w.  j av a 2  s. co  m*/
    try {
        price = Double.valueOf(ebayAd.getPrice().replaceFirst("EUR", ""));
    } catch (Exception e) {
        price = Double.valueOf(0);
    }

    Long provinceId = Long.valueOf(1);

    return new NewExternalClassifiedAdTO(Long.valueOf(categoryId), null, price, ebayAd.getTitle(),
            ebayAd.getDescription(), null, null, provinceId, Integer.valueOf(ClassifiedAd.SOURCE_EBAY),
            ebayAd.getUrl(), Integer.valueOf(0), Integer.valueOf(ClassifiedAd.STATE_ACTIVE));
}

From source file:Main.java

private static boolean isNumber(String n) {
    try {//from www .  ja v  a2 s  .c  o m
        double d = Double.valueOf(n).doubleValue();
        return true;
    } catch (NumberFormatException e) {
        return false;
    }
}

From source file:Main.java

public static double getJulDate() {
    Calendar cal = Calendar.getInstance();
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH) + 1;
    int day = cal.get(Calendar.DAY_OF_MONTH);
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    int minute = cal.get(Calendar.MINUTE);
    int second = cal.get(Calendar.SECOND);
    double extra = (100.0 * year) + month - 190002.5;
    double julianDay = (367.0 * year) - (Math.floor(7.0 * (year + Math.floor((month + 9.0) / 12.0)) / 4.0))
            + Math.floor((275.0 * month) / 9.0) + day + ((hour + ((minute + (second / 60.0)) / 60.0)) / 24.0)
            + 1721013.5 - ((0.5 * extra) / Math.abs(extra)) + 0.5;
    DecimalFormat sixDigitFormat = new DecimalFormat("#.######");
    return Double.valueOf(sixDigitFormat.format(julianDay));
}

From source file:Main.java

public static double[] read_array(String filename) throws Exception {
    FileReader f = new FileReader(filename);
    BufferedReader inp = new BufferedReader(f);

    String str = inp.readLine();/* ww  w. j  ava  2 s. c  o  m*/
    int nl = 0;
    while (str != null) {
        nl++;
        str = inp.readLine();
    }

    inp.close();
    f.close();

    double[] res = new double[nl];
    f = new FileReader(filename);
    inp = new BufferedReader(f);
    for (int i = 0; i < nl; i++) {
        str = inp.readLine();
        res[i] = Double.valueOf(str).doubleValue();
    }

    inp.close();
    f.close();

    return res;
}

From source file:com.yoncabt.ebr.executor.jasper.Convert.java

private static <T> T str2Number(String val, Class<T> valueClass) {
    if (StringUtils.isBlank(val)) {
        return null;
    }//from   ww  w .ja va2  s.c o  m
    if (valueClass == Integer.class) {
        return (T) Integer.valueOf(val);
    }
    if (valueClass == Long.class) {
        return (T) Long.valueOf(val);
    }
    if (valueClass == Short.class) {
        return (T) Short.valueOf(val);
    }
    if (valueClass == Double.class) {
        return (T) Double.valueOf(val);
    }
    if (valueClass == BigDecimal.class) {
        return (T) new BigDecimal(val);
    }
    throw new IllegalArgumentException(val.getClass() + "->" + valueClass.getName());
}

From source file:net.ceos.project.poi.annotated.bean.FreeElementObjectBuilder.java

/**
 * Create a FreeElementObject for tests.
 * /*from  w w w .  j  a v  a  2s. c o m*/
 * @return the {@link FreeElementObject}
 */
public static FreeElementObject buildFreeElementObject(int multiplier) {
    FreeElementObject toValidate = new FreeElementObject();

    toValidate.setFreeString("some string");
    toValidate.setFreeDouble(Double.valueOf("11.21") * multiplier);
    toValidate.setFreePrimitiveInt(12 * multiplier);
    toValidate.setFreeDate(new Date());
    toValidate.setFreeLong(Long.valueOf("1234567890") * multiplier);
    toValidate.setFreePrimitiveBoolean(Boolean.FALSE);
    // TODO add new fields below

    return toValidate;
}

From source file:net.ceos.project.poi.annotated.bean.BasicObjectBuilder.java

/**
 * Create a BasicObject for tests./*from ww  w. java 2 s  . c  o m*/
 * 
 * @return the {@link BasicObject}
 */
public static BasicObject buildBasicObject(int multiplier) {
    BasicObject toValidate = new BasicObject();

    toValidate.setDateAttribute(new Date());
    toValidate.setStringAttribute("some string");
    toValidate.setDoubleAttribute(Double.valueOf("25.3") * multiplier);
    toValidate.setLongAttribute(Long.valueOf("1234567890") * multiplier);
    toValidate.setBooleanPrimitiveAttribute(true);
    toValidate.setFloatPrimitiveAttribute(11.1125f * multiplier);
    toValidate.setUnitFamily(UnitFamily.COMPONENTS);
    toValidate.setBigDecimalAttribute(BigDecimal.valueOf(24.777).multiply(BigDecimal.valueOf(multiplier)));
    // TODO add new fields below

    return toValidate;
}

From source file:net.ceos.project.poi.annotated.bean.AutoResizeObjectBuilder.java

/**
 * Create a AutoResizeObject for tests./*w  ww  .  j ava  2s . co  m*/
 * 
 * @return the {@link AutoResizeObject}
 */
public static AutoResizeObject buildAutoResizeObject(int multiplier) {
    AutoResizeObject toValidate = new AutoResizeObject();

    toValidate.setDateAttribute(new Date());
    toValidate.setStringAttribute("some string");
    toValidate.setDoubleAttribute(Double.valueOf("25.3") * multiplier);
    toValidate.setLongAttribute(Long.valueOf("1234567890") * multiplier);
    toValidate.setBooleanPrimitiveAttribute(true);
    toValidate.setFloatPrimitiveAttribute(11.1125f * multiplier);
    toValidate.setUnitFamily(UnitFamily.COMPONENTS);
    toValidate.setBigDecimalAttribute(BigDecimal.valueOf(24.777).multiply(BigDecimal.valueOf(multiplier)));
    // TODO add new fields below

    return toValidate;
}

From source file:Main.java

/**
 * Decodes a String into an object of the specified type. If the object
 * type is not supported, null will be returned.
 *
 * @param type the type of the property.
 * @param value the encode String value to decode.
 * @return the String value decoded into the specified type.
 * @throws Exception If decoding failed due to an error.
 */// w w  w  . jav  a 2  s .  c  o m
private static Object decode(Class type, String value) throws Exception {
    if (type.getName().equals("java.lang.String")) {
        return value;
    }
    if (type.getName().equals("boolean")) {
        return Boolean.valueOf(value);
    }
    if (type.getName().equals("int")) {
        return Integer.valueOf(value);
    }
    if (type.getName().equals("long")) {
        return Long.valueOf(value);
    }
    if (type.getName().equals("float")) {
        return Float.valueOf(value);
    }
    if (type.getName().equals("double")) {
        return Double.valueOf(value);
    }
    if (type.getName().equals("java.lang.Class")) {
        return Class.forName(value);
    }
    return null;
}

From source file:net.ceos.project.poi.annotated.bean.cascade.CascadeL3Builder.java

/**
 * Create a CascadeL3 for tests./*from   w  ww .  j ava  2 s.  c  om*/
 * 
 * @return the {@link CascadeL3}
 */
public static CascadeL3 buildCascadeL3(int multiplier) {
    CascadeL3 toValidate = new CascadeL3();

    toValidate.setDateAttribute(new Date());
    toValidate.setStringAttribute("Cascade L3");
    toValidate.setIntegerAttribute(46 * multiplier);
    toValidate.setDoubleAttribute(Double.valueOf("25.3") * multiplier);
    toValidate.setLongAttribute(Long.valueOf("1234567890") * multiplier);
    toValidate.setBooleanAttribute(Boolean.FALSE);
    /* create sub object Job */
    Job job = new Job();
    job.setJobCode(0005);
    job.setJobFamily("Family Job Name L2");
    job.setJobName("Job Name L2");
    toValidate.setJob(job);

    // TODO add new fields below

    return toValidate;
}