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:ec.edu.distri.clientejava.protocolo.model.ServicioAdicional.java

public ServicioAdicional() {
    costo = new BigDecimal(BigInteger.ZERO);

}

From source file:ru.transaction.util.TransactionSumCalculatorRecursive.java

@Override
public BigDecimal calculateSum(BigDecimal currentSum, TransactionEntity transaction) {
    currentSum = currentSum.add(new BigDecimal(transaction.getAmount()));
    Collection<TransactionEntity> childTransactions = transactionRepository.findByParentId(transaction.getId());
    for (TransactionEntity childTransaction : childTransactions) {
        currentSum = calculateSum(currentSum, childTransaction);
    }//from w w w .java2  s  .  com
    return currentSum;
}

From source file:de.csdev.ebus.command.datatypes.std.AbstractEBusTypeUnsignedNumber.java

@Override
public BigDecimal decodeInt(byte[] data) throws EBusTypeException {

    byte[] clone = ArrayUtils.clone(data);
    ArrayUtils.reverse(clone);//from   w w  w .jav a 2  s  .  c  om

    return new BigDecimal(new BigInteger(1, clone));
}

From source file:gov.nih.nci.calims2.ui.administration.customerservice.serviceitem.ServiceItemHelper.java

/**
 * Gets the total for the given service.
 * /*  w ww.  j  ava2s . c o  m*/
 * @param service The service for which the calculation must be done
 * @return the total for the given service. or null if any serviceItem is not computable
 */
public static BigDecimal getServiceTotal(Service service) {
    BigDecimal subtotal = new BigDecimal("0");
    Set<ServiceItem> serviceItems = service.getServiceItemCollection();
    if (serviceItems != null) {
        for (ServiceItem serviceItem : serviceItems) {
            BigDecimal itemSubTotal = getsubTotalValue(serviceItem);
            if (itemSubTotal == null) {
                return null;
            }
            subtotal = subtotal.add(ServiceItemHelper.getsubTotalValue(serviceItem));
        }

    }
    return subtotal;
}

From source file:com.shenit.commons.utils.Formatter.java

/**
 * ?//  w  w  w.  j  a va 2  s  .c  om
 * @param num 
 * @param scale ????
 * @return
 */
public static String formatPrice(double num) {
    return new BigDecimal(num).setScale(2, RoundingMode.CEILING).toPlainString();
}

From source file:com.surfs.storage.web.utils.Stringutils.java

public static String sumSpace(String totalSpace, String currentSpace) {
    if (StringUtils.isBlank(totalSpace)) {
        return convertToKB(currentSpace);
    }//from w  ww. ja  va  2 s. c  o m

    //String total = convertToKB(totalSpace);
    String current = convertToKB(currentSpace);
    BigDecimal sum = new BigDecimal(totalSpace);
    long sumNum = sum.add(new BigDecimal(current)).longValue();

    //BigDecimal sumTB = new BigDecimal(sumNum);
    //double divSum = sumTB.divide(new BigDecimal("1048576"), 2, BigDecimal.ROUND_HALF_UP).doubleValue();

    //return String.valueOf(divSum).concat("T");
    return String.valueOf(sumNum);
}

From source file:kenh.expl.functions.Round.java

public double process(double number, int scale) {
    BigDecimal b = new BigDecimal(number);
    number = b.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
    return number;
}

From source file:de.olivergierke.whoops.core.DefaultFeeProvider.java

public BigDecimal getTransactionFee(Instrument instrument) {
    return new BigDecimal(0);
}

From source file:com.pegadaian.controller.HargaEmasController.java

@RequestMapping(method = RequestMethod.GET)
//    public HargaEmas hargaEmas(){
public List<HargaEmas> hargaEmas() {
    List<HargaEmas> listHarga = new ArrayList<>();

    HargaEmas limaGram = new HargaEmas();
    limaGram.setTanggal(new Date());
    limaGram.setHarga(new BigDecimal("2690.00"));
    limaGram.setBerat(5);/* w ww.  java  2  s .  c o m*/
    limaGram.setHargaBeli(new BigDecimal("5180.00"));
    limaGram.setHargaJual(new BigDecimal("5360.00"));
    listHarga.add(limaGram);

    HargaEmas sepuluhGram = new HargaEmas();
    sepuluhGram.setTanggal(new Date());
    sepuluhGram.setHarga(new BigDecimal("5330.00"));
    sepuluhGram.setBerat(10);
    listHarga.add(sepuluhGram);

    HargaEmas duaPuluhLimaGram = new HargaEmas();
    duaPuluhLimaGram.setTanggal(new Date());
    duaPuluhLimaGram.setHarga(new BigDecimal("2690.00"));
    duaPuluhLimaGram.setBerat(25);
    listHarga.add(duaPuluhLimaGram);

    HargaEmas limaPuluhGram = new HargaEmas();
    limaPuluhGram.setTanggal(new Date());
    limaPuluhGram.setHarga(new BigDecimal("26450.00"));
    limaPuluhGram.setBerat(50);
    listHarga.add(limaPuluhGram);

    HargaEmas seratusGram = new HargaEmas();
    seratusGram.setTanggal(new Date());
    seratusGram.setHarga(new BigDecimal("52850.00"));
    seratusGram.setBerat(100);
    listHarga.add(seratusGram);

    HargaEmas duaRatusLimaPuluhGram = new HargaEmas();
    duaRatusLimaPuluhGram.setTanggal(new Date());
    duaRatusLimaPuluhGram.setHarga(new BigDecimal("132000.00"));
    duaRatusLimaPuluhGram.setBerat(250);
    listHarga.add(duaRatusLimaPuluhGram);

    HargaEmas satuKiloGram = new HargaEmas();
    satuKiloGram.setTanggal(new Date());
    satuKiloGram.setHarga(new BigDecimal("527000.00"));
    satuKiloGram.setBerat(1);
    listHarga.add(satuKiloGram);

    return listHarga;
    //        return limaGram;
}

From source file:org.whispersystems.bithub.config.BithubConfiguration.java

public BigDecimal getPayoutRate() {
    return new BigDecimal(payout);
}