List of usage examples for java.math BigDecimal valueOf
public static BigDecimal valueOf(double val)
From source file:livhuwani.rambuda.policy_app.services.Impl.PolicyQuoteCrudServiceImpl.java
@Override public PolicyQuote createPolicyQuotes(Person person, Policy policy) { PolicyQuote quote = new PolicyQuote(); quote.setId(Long.MAX_VALUE + 1); quote.setPerson(person);/*from w ww . j a v a 2 s .c o m*/ quote.setPolicy(policy); quote.setQuoteAmount(BigDecimal.valueOf(3200)); quote.setQuoteStatus(Boolean.TRUE); quote.setQuoteDate(DateTime.now()); PolicyQuote savedQuote = policyQuoteRepository.saveAndFlush(quote); return savedQuote; }
From source file:com.autentia.tnt.faces.components.property.BookMock.java
public BookMock(String title, String summary, int price) { this.title = title; this.summary = summary; this.price = BigDecimal.valueOf(price); }
From source file:net.eusashead.hateoas.response.impl.CustomerRepository.java
public Page<Customer> listCustomers(Pageable page) { List<Customer> orders = new ArrayList<Customer>(); for (int i = 0; i < page.getPageSize(); i++) { orders.add(new Customer(i, BigDecimal.valueOf(Math.random() * 100), new Date(Math.round(123456789l * Math.random())))); }// w ww . jav a 2 s. c om return new PageImpl<Customer>(orders, page, 95); }
From source file:com.livhuwani.rambuda.policyquotationapp.services.Impl.PolicyQuoteCrudServiceImpl.java
@Override public PolicyQuote createPolicyQuotes(Person person, Policy policy) { PolicyQuote quote = new PolicyQuote(); quote.setId(Long.MAX_VALUE + 1); quote.setPerson(person);/* w ww. ja v a2 s . co m*/ quote.setPolicy(policy); quote.setQuoteAmount(BigDecimal.valueOf(3200)); quote.setQuoteStatus(Boolean.TRUE); quote.setQuoteDate(new Date()); PolicyQuote savedQuote = policyQuoteRepository.saveAndFlush(quote); return savedQuote; }
From source file:net.ceos.project.poi.annotated.bean.PropagationHorizontalObjectBuilder.java
/** * Create a PropagationHorizontalObject for tests. * //from w w w .ja va 2 s . c o m * @return the {@link PropagationHorizontalObject} */ public static PropagationHorizontalObject buildPropagationHorizontalObject(int multiplier) { PropagationHorizontalObject toValidate = new PropagationHorizontalObject(); toValidate.setDateAttribute(new Date()); toValidate.setStringAttribute("some string"); toValidate.setIntegerAttribute(46 * multiplier); toValidate.setBooleanAttribute(Boolean.FALSE); toValidate.setDoublePrimitiveAttribute(44.6 * multiplier); toValidate.setLongPrimitiveAttribute(987654321L * multiplier); toValidate.setFloatAttribute(14.765f * 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:com.haulmont.timesheets.global.WorkTimeConfigBean.java
public BigDecimal getWorkHourForDay() { return getWorkHourForWeek().divide(BigDecimal.valueOf(getWorkDaysCount()), BigDecimal.ROUND_HALF_UP); }
From source file:roboguice.calculator.util.MockRpnStack.java
public MockRpnStack() { add(BigDecimal.valueOf(1)); add(BigDecimal.valueOf(2)); add(BigDecimal.valueOf(3)); }
From source file:cherry.foundation.crypto.SecureBigDecimalEncoderTest.java
@Test public void testEncodeDecode() throws Exception { SecureBigDecimalEncoder encoder = createSecureBigDecimalEncoder(); for (int i = 0; i < 100; i++) { BigDecimal plain = BigDecimal.valueOf(random.nextDouble()); String crypto = encoder.encode(plain); assertThat(crypto, is(not(plain.toString()))); assertThat(encoder.decode(crypto), is(plain)); }//from w w w. j a v a2 s . c o m }
From source file:com.qcadoo.model.api.BigDecimalUtils.java
/** * Converts value, if null returns one//from w ww . j ava 2 s . c om * * @param value * value * * @return value or one */ public static BigDecimal convertNullToOne(final Object value) { if (value == null) { return BigDecimal.ONE; } if (value instanceof BigDecimal) { return (BigDecimal) value; } return BigDecimal.valueOf(Double.valueOf(value.toString())); }
From source file:com.startup.musicstore.test.repository.AlbumRepositoryTest.java
@Test(enabled = true) public void create() { repo = ctx.getBean(AlbumRepository.class); Album album = new Album.Builder("Jazz").inventory(10).unitPrice(BigDecimal.valueOf(100.00)).build(); repo.save(album);/*from w ww . j av a2 s. c o m*/ id = album.getId(); Assert.assertNotNull(id); }