List of usage examples for java.math BigDecimal ZERO
BigDecimal ZERO
To view the source code for java.math BigDecimal ZERO.
Click Source Link
From source file:com.itellity.comp.type.finance.MonetaryAmountMH.java
/** * Converts a BigDecimal and a Currency to a MonetaryAmount * * @param entity// w ww . j a v a 2s . co m * @param amount * @param currency * * @return */ public static MonetaryAmount parseValue(Entity entity, BigDecimal amount, Currency currency) { MonetaryAmount money = null; if ((amount == null || amount.intValue() == 0) && ((currency == null) || currency.isUndefined())) { money = MonetaryAmount.UNDEFINED; } else { try { money = new MonetaryAmount(amount == null ? BigDecimal.ZERO : amount, currency); } catch (Exception e) { LOG.error(e.getMessage(), e); money = MonetaryAmount.UNDEFINED; } } return money; }
From source file:com.genscript.gsscm.product.dto.RoyaltyProductDTO.java
public RoyaltyProductDTO() { this.sellingPriceCmsn = BigDecimal.ZERO; this.grossProfitCmsn = BigDecimal.ZERO; this.unitRateCmsn = BigDecimal.ZERO; }
From source file:Main.java
/** * Write a {@link BigDecimal} value into XML output. * * @param value//ww w .ja v a 2 s . com * value to write * * @param min * minimal value * * @param max * maximal value * * @param precision * number of decimal places * * @return * XML string * * @throws IllegalArgumentException * if a validation error occured */ private static String printDecimal(BigDecimal value, BigDecimal min, BigDecimal max, int precision, boolean zeroIncluded) { if (value == null) { throw new IllegalArgumentException("The provided double value NULL is invalid!"); } value = value.setScale(precision, BigDecimal.ROUND_HALF_UP); if (min != null && value.compareTo(min) <= 0) { if (!zeroIncluded || !BigDecimal.ZERO.equals(value)) { throw new IllegalArgumentException( "The provided double value " + value + " is too small (minimum is " + min + ")!"); } } if (max != null && value.compareTo(max) >= 0) { throw new IllegalArgumentException( "The provided double value " + value + " is too high (maximum is " + max + ")!"); } return DatatypeConverter.printDecimal(value); }
From source file:de.tsystems.mms.apm.performancesignature.util.PerfSigUIUtils.java
public static BigDecimal round(final double d, final int scale) { try {/*from w w w. j a v a2s . c o m*/ return BigDecimal.valueOf(d).setScale(d % 1 == 0 ? 0 : scale, BigDecimal.ROUND_HALF_UP); } catch (NumberFormatException ex) { if (Double.isInfinite(d)) { return BigDecimal.valueOf(d); } else { return BigDecimal.ZERO; } } }
From source file:fi.iki.dezgeg.matkakorttiwidget.gui.MatkakorttiWidgetApp.java
public static synchronized List<Card> getCardList() throws Exception { String username = prefs.getString("username", "<not set>"); String password = prefs.getString("password", ""); if (DEBUG && username.equals("dezgegt")) return Arrays.asList(new Card("Tyhja", "a", BigDecimal.ZERO, null), new Card("Rahaa", "b", BigDecimal.TEN, null), new Card("Kautta", "c", BigDecimal.ZERO, new Date(113, 11, 28)), new Card("Raha+Kausi", "d", new BigDecimal("99.99"), new Date()), new Card("Paljon rahaa", "e", new BigDecimal("199.99"), null)); else if (DEBUG && username.equals("dezgege")) return Arrays.asList(); return new MatkakorttiApi(username, password).getCards(); }
From source file:com.creditcloud.carinsurance.local.CarInsuranceFeeLocalBean.java
/** * ?/*from w ww .ja v a 2s.co m*/ * @param repayment * @return */ public BigDecimal overdueFee(CarInsuranceRepayment repayment) { if (repayment == null) { return BigDecimal.ZERO; } if (LocalDate.now().toDate().compareTo(repayment.getDueDate()) <= 0) { return BigDecimal.ZERO; } BigDecimal days = BigDecimal.ZERO; // if (repayment.getRepayDate() != null) { long repayTime = repayment.getRepayDate().getTime(); long dueTime = repayment.getDueDate().getTime(); days = BigDecimal.valueOf((repayTime - dueTime) / DateUtils.MILLIS_PER_DAY); if (days.compareTo(BigDecimal.ZERO) < 0) { return BigDecimal.ZERO; } } else { long nowTime = LocalDate.now().plusDays(1).toDate().getTime(); long dueTime = repayment.getDueDate().getTime(); days = BigDecimal.valueOf((nowTime - dueTime) / DateUtils.MILLIS_PER_DAY); } BigDecimal penaltyAmount = BigDecimal.ZERO; //??? Fee overduePenaltyFee = configManager.getCarInsuranceConfig().getPenaltyFee(); penaltyAmount = FeeUtils.calculate(overduePenaltyFee, repayment.getAmountPrincipal()).multiply(days) .setScale(NumberConstant.DEFAULT_SCALE, NumberConstant.ROUNDING_MODE); return penaltyAmount; }
From source file:es.logongas.encuestas.modelo.resultados.InferenciaEstadistica.java
public InferenciaEstadistica(EstadisticaDescriptiva estadisticaDescriptiva, BigDecimal nivelConfianza, int numDecimals) { this.numDecimals = numDecimals; if (nivelConfianza.compareTo(BigDecimal.ZERO) <= 0) { throw new IllegalArgumentException("El nivelConfianza debe ser mayor que 0"); }//w ww .j a va2 s. c o m if (nivelConfianza.compareTo(BigDecimal.ONE) >= 0) { throw new IllegalArgumentException("El nivelConfianza debe ser menor que 1"); } TDistribution tDistribution = new TDistribution(estadisticaDescriptiva.getNumMuestras() - 1); double t = tDistribution.inverseCumulativeProbability(nivelConfianza.doubleValue()); BigDecimal delta = new BigDecimal(t * (estadisticaDescriptiva.getDesviacionEstandar().doubleValue() / Math.sqrt(estadisticaDescriptiva.getNumMuestras()))); BigDecimal min = estadisticaDescriptiva.getMedia().subtract(delta).setScale(this.numDecimals, RoundingMode.HALF_UP); BigDecimal max = estadisticaDescriptiva.getMedia().add(delta).setScale(this.numDecimals, RoundingMode.HALF_UP); intervaloConfianzaMedia = new IntervaloConfianza(min, max, nivelConfianza); }
From source file:com.skubit.iab.activities.TransactionDetailsActivity.java
private static final String formatCurrencyAmount(BigDecimal balanceNumber) { NumberFormat numberFormat = NumberFormat.getInstance(Locale.getDefault()); numberFormat.setMaximumFractionDigits(8); numberFormat.setMinimumFractionDigits(4); if (balanceNumber.compareTo(BigDecimal.ZERO) == -1) { balanceNumber = balanceNumber.multiply(new BigDecimal(-1)); }/* ww w . j a v a 2 s. c om*/ return numberFormat.format(balanceNumber); }
From source file:com.creditcloud.interestbearing.model.InterestBearingUserFundChange.java
public InterestBearingUserFundChangeDirection getChangeDirection() { if (changeAmount == null) { return InterestBearingUserFundChangeDirection.NO_CHANGE; }/*from ww w. j av a 2 s .c o m*/ if (changeAmount.equals(BigDecimal.ZERO)) { return InterestBearingUserFundChangeDirection.NO_CHANGE; } InterestBearingUserFundChangeDirection direction = (changeAmount.compareTo(BigDecimal.ZERO) > 0) ? InterestBearingUserFundChangeDirection.INCREASED : InterestBearingUserFundChangeDirection.DECREASED; return direction; }
From source file:com.itellity.comp.type.finance.MonetaryAmountMH.java
/** * dispatches a Price// ww w . j av a 2 s . c o m * * @param money * * @return BigDecimal */ public static BigDecimal dispatchValueToAmount(MonetaryAmount money) { if ((money == null) || (money.isUndefined())) { return BigDecimal.ZERO; } else { return money.getAmount(); } }