Example usage for java.math BigDecimal BigDecimal

List of usage examples for java.math BigDecimal BigDecimal

Introduction

In this page you can find the example usage for java.math BigDecimal BigDecimal.

Prototype

public BigDecimal(long val) 

Source Link

Document

Translates a long into a BigDecimal .

Usage

From source file:es.tena.foundation.util.POIUtil.java

public static String getCelda(HSSFCell cellSugg) {
    String suggestion = "";
    if (cellSugg != null) {
        if (cellSugg.getCellType() == HSSFCell.CELL_TYPE_STRING) {
            suggestion = StringUtil.trim(StringEscapeUtils.escapeSql(cellSugg.getStringCellValue()));
        } else if (cellSugg.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
            BigDecimal big = new BigDecimal(cellSugg.getNumericCellValue());
            suggestion = big.toString();
        } // no hace falta else
        else {// ww w  .j  av a 2s. com
            suggestion = StringUtil.trim(StringEscapeUtils.escapeSql(cellSugg.getStringCellValue()));
        }
        suggestion = SQLUtil.replace(suggestion);
    }
    return suggestion;
}

From source file:org.atomspace.ultrahouse3000.translator.Weather2DocumentTranslator.java

@Override
public void process(Exchange exchange) throws Exception {

    JsonObject weather = (JsonObject) new JsonParser().parse(exchange.getIn().getBody(String.class));
    BigDecimal temperatur = weather.get("main").getAsJsonObject().get("temp").getAsBigDecimal();
    temperatur = temperatur.subtract(new BigDecimal("272.15"));
    exchange.getIn().setHeader("temperatur", temperatur);

    super.process(exchange);

}

From source file:be.ceau.chart.dataset.DoughnutDataset.java

/**
 * Sets the backing data list to the argument, replacing any data already
 * added or set//from   w  w  w  . jav a 2 s  .  c  o  m
 * 
 * @param data
 *            The data to plot in a line
 */
public DoughnutDataset setData(int... data) {
    clearData();
    if (data != null) {
        for (int i = 0; i < data.length; i++) {
            this.data.add(new BigDecimal(data[i]));
        }
    }
    return this;
}

From source file:mondrian.util.UtilCompatibleJdk14.java

/**
 * This generates a BigDecimal that can have a precision that does
 * not reflect the precision of the input double.
 *
 * @param d input double/*from   www.  jav  a  2s .  c  o  m*/
 * @return BigDecimal
 */
public BigDecimal makeBigDecimalFromDouble(double d) {
    return new BigDecimal(d);
}

From source file:com.xumpy.thuisadmin.dao.RekeningDaoTest.java

@Test
@Transactional(value = "jpaTransactionManager")
public void testTotalRekening() {
    userInfo.setPersoon(personenDao.findOne(1));
    assertEquals(rekeningenDao.totalAllRekeningen(userInfo.getPersoon().getPk_id()), new BigDecimal(2250));
}

From source file:de.olivergierke.whoops.equities.EquityTransactionFeeProvider.java

public BigDecimal getTransactionFee(Instrument instrument) {

    Equity equity = (Equity) instrument;

    return VMWARE.equals(equity.getIssuer()) ? TransactionFeeProvider.NO_FEE : new BigDecimal(10.5);
}

From source file:alfio.model.PriceContainerTest.java

@Test
public void getFinalPriceInputDoNotApplyVat() throws Exception {
    Stream.of(PriceContainer.VatStatus.INCLUDED, PriceContainer.VatStatus.NONE).forEach(vatStatus -> {
        PriceContainerImpl vs = new PriceContainerImpl(1000, "CHF", new BigDecimal("30.00"), vatStatus);
        assertEquals(new BigDecimal("10.00"), vs.getFinalPrice());
        PromoCodeDiscount promoCodeDiscount = mock(PromoCodeDiscount.class);
        when(promoCodeDiscount.getDiscountAmount()).thenReturn(100, 10);
        when(promoCodeDiscount.getFixedAmount()).thenReturn(true, false);
        when(promoCodeDiscount.getDiscountType()).thenReturn(PromoCodeDiscount.DiscountType.FIXED_AMOUNT,
                PromoCodeDiscount.DiscountType.PERCENTAGE);

        vs = new PriceContainerImpl(1100, "CHF", new BigDecimal("30.00"), vatStatus, promoCodeDiscount);
        assertEquals(String.format("vatStatus: %s", vatStatus.name()), new BigDecimal("10.00"),
                vs.getFinalPrice());/*from ww w  . jav a2  s .  com*/

        vs = new PriceContainerImpl(1000, "CHF", new BigDecimal("30.00"), vatStatus, promoCodeDiscount);
        assertEquals(String.format("vatStatus: %s", vatStatus.name()), new BigDecimal("9.00"),
                vs.getFinalPrice());
    });
}

From source file:com.github.iexel.fontus.web.ApplicationListenerBean.java

private void populateDB() {
    try {//w  w w . j a va  2s . co  m
        productsService.createProduct(new Product(0, "Java SE (book)", new BigDecimal("40.50")));
        productsService.createProduct(new Product(0, "Spring MVC (book)", new BigDecimal("52.00")));
        productsService.createProduct(new Product(0, "Oracle (book)", new BigDecimal("31.20")));
        productsService.createProduct(new Product(0, "SQL (book)", new BigDecimal("45.50")));
        productsService.createProduct(new Product(0, "Spring (book)", new BigDecimal("51.00")));
        productsService.createProduct(new Product(0, "PHP (book)", new BigDecimal("33.20")));
        productsService.createProduct(new Product(0, "HTML (book)", new BigDecimal("41.50")));
    } catch (ServiceException e) {
        e.printStackTrace();
    }
}

From source file:com.pavlovmedia.oss.osgi.gelf.lib.GelfMessageSerializer.java

@Override
public void serialize(GelfMessage value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException, JsonProcessingException {
    jgen.writeStartObject();/*from  w ww.j  a v a2 s .c o  m*/
    jgen.writeStringField("version", value.version);
    jgen.writeStringField("host", value.host);
    jgen.writeStringField("short_message", value.short_message);
    jgen.writeStringField("full_message", value.full_message);

    BigDecimal bd = new BigDecimal(value.timestamp);
    bd = bd.divide(new BigDecimal(1000), BigDecimal.ROUND_DOWN);
    jgen.writeNumberField("timestamp", bd);
    jgen.writeNumberField("level", value.level);
    for (String key : value.additionalFields.keySet()) {
        jgen.writeStringField("_" + key, value.additionalFields.get(key));
    }
    jgen.writeEndObject();
}

From source file:org.springsource.restbucks.training.core.MonetaryAmount.java

/**
 * Creates a new {@link MonetaryAmount} instance with the given value and {@link Currency}.
 * //from w w  w  . j  ava2 s  . c  o  m
 * @param currency must not be {@literal null}.
 * @param value
 */
public MonetaryAmount(Currency currency, double value) {
    this(currency, new BigDecimal(value));
}