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:com.cnd.greencube.web.base.template.method.CurrencyMethod.java

@SuppressWarnings("rawtypes")
public Object exec(List arguments) throws TemplateModelException {
    if (arguments != null && !arguments.isEmpty() && arguments.get(0) != null
            && StringUtils.isNotEmpty(arguments.get(0).toString())) {
        boolean showSign = false;
        boolean showUnit = false;
        if (arguments.size() == 2) {
            if (arguments.get(1) != null) {
                showSign = Boolean.valueOf(arguments.get(1).toString());
            }//from w w w.  j av a  2 s  .c o m
        } else if (arguments.size() > 2) {
            if (arguments.get(1) != null) {
                showSign = Boolean.valueOf(arguments.get(1).toString());
            }
            if (arguments.get(2) != null) {
                showUnit = Boolean.valueOf(arguments.get(2).toString());
            }
        }

        BigDecimal amount = new BigDecimal(arguments.get(0).toString());
        String price = CurrencyUtils.setScale(amount).toString();
        if (showSign) {
            price = "" + price;
        }
        if (showUnit) {
            price += "";
        }
        return new SimpleScalar(price);
    }
    return null;
}

From source file:be.ceau.chart.datapoint.ScatterDataPoint.java

public ScatterDataPoint setX(int x) {
    this.x = new BigDecimal(x);
    return this;
}

From source file:by.creepid.docsreporter.AbstractDocsReporterIT.java

protected Project createProjectSample() {
    Project project = new Project("project name", new Date(), new BigDecimal("123.123"));

    project.setUrl("https://github.com/creepid/DocsReporter");

    Manager manager = new Manager("Mike", "<b>Green</b>", 5);
    String string = "January 2, 1982";
    Date birthDate = null;//w  w  w. ja  v  a2 s  .  c  o m
    try {
        birthDate = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(string);
    } catch (ParseException ex) {
        Logger.getLogger(ReportTemplateIT.class.getName()).log(Level.SEVERE, null, ex);
    }

    List<Role> roles = new ArrayList<Role>();
    roles.add(new Role("Programmer"));
    roles.add(new Role("GUI programmer"));

    manager.setBirthDate(birthDate);

    project.setManager(manager);

    project.add(new DeveloperWithPhoto("<b>ZERR</b>", "Angelo", "angelo.zerr@gmail.com", birthDate,
            this.getFileBytes(photoFolder + "photo2.jpeg"), roles));
    project.add(new DeveloperWithPhoto("<b>Leclercq</b>", "Pascal", "pascal.leclercq@gmail.com", null,
            this.getFileBytes(photoFolder + "photo1.jpeg"), roles, WorkingStatus.freelance));

    project.add(new DeveloperWithPhoto("<b>Leclercq</b>", "Pascal", null, birthDate,
            this.getFileBytes(photoFolder + "photo1.jpeg"), roles));

    roles = new ArrayList<Role>();
    roles.add(new Role("System programmer"));
    roles.add(new Role("Admin"));
    project.add(new DeveloperWithPhoto("<b>Arnold</b>", "Brown", "arnoldbrown@yahoo.com", birthDate,
            this.getFileBytes(photoFolder + "photo2.jpeg"), roles));

    roles = new ArrayList<Role>();
    roles.add(new Role("Architect"));
    project.add(new DeveloperWithPhoto("<b>Jim</b>", "Smith", "jimmythebest@tut.by", birthDate,
            this.getFileBytes(photoFolder + "photo3.jpeg"), roles, WorkingStatus.halfTime));

    project.setLogo(this.getFileBytes(photoFolder + imageName));

    return project;
}

From source file:net.groupbuy.plugin.oss.OssController.java

/**
 * /*from w ww  .j a va2 s .co m*/
 */
@RequestMapping(value = "/install", method = RequestMethod.POST)
public @ResponseBody Message install() {
    String specificationVersion = System.getProperty("java.specification.version");
    if (StringUtils.isNotEmpty(specificationVersion)) {
        BigDecimal version = new BigDecimal(specificationVersion);
        if (version.compareTo(new BigDecimal("1.6")) < 0) {
            return Message.error("admin.plugin.oss.unsupportedJavaVersion");
        }
    }
    if (!ossPlugin.getIsInstalled()) {
        PluginConfig pluginConfig = new PluginConfig();
        pluginConfig.setPluginId(ossPlugin.getId());
        pluginConfig.setIsEnabled(false);
        pluginConfigService.save(pluginConfig);
    }
    return SUCCESS_MESSAGE;
}

From source file:com.alibaba.sample.petstore.dal.dao.ProductItemDaoTests.java

@Test
public void getItemById() {
    ProductItem item = productItemDao.getItemById("EST-1");

    assertEquals("EST-1", item.getProductItemId());
    assertEquals("FI-SW-01", item.getProductId());
    assertEquals(new BigDecimal("16.50"), item.getListPrice());
    assertEquals(new BigDecimal("10.00"), item.getUnitCost());
    assertEquals(1, item.getSupplierId());
    assertEquals("P", item.getStatus());
    assertEquals("Large", item.getAttribute1());
}

From source file:org.intan.hotelMaestro.springdata.RoomTypeRepositoryIntegrationTest.java

@Test
public void createRoomType() {

    RoomType roomType = new RoomType("Single Room Type", new BigDecimal(49.99), "Single");
    roomType = roomTypeRepository.save(roomType);
    assertThat(roomType.getId(), is(notNullValue()));
}

From source file:com.dolgoter.configuration.TrainerConfig.java

@Bean
@Qualifier("invalid_secondname")
public Trainer getTrainerInvalidSecondname() {
    Trainer mour = new Trainer("Jose", "Mourinho2", 45, new ArrayList<Team>());
    mour.setSalary(new Salary(new BigDecimal(1000000)));
    return mour;//from w  w  w.j a va2 s .c o  m
}

From source file:io.restassured.itest.java.BigDecimalITest.java

@Test
public void big_decimal_works() {
    when().get("/amount").then().body("amount", equalTo(new BigDecimal("250.00")));
}

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

public static String convertToKB(String total) {
    if (StringUtils.isBlank(total)) {
        return total;
    }/*w ww . j  av  a  2  s.c o  m*/

    String space = total.substring(0, total.length() - 1);
    String unit = total.substring(total.length() - 1, total.length());

    BigDecimal t = new BigDecimal(space);
    BigDecimal multiply = null;

    if (unit.equalsIgnoreCase("M")) {
        multiply = t.multiply(new BigDecimal("1048576"));
    } else if (unit.equalsIgnoreCase("T")) {
        multiply = t.multiply(new BigDecimal("1099511627776"));
    } else if (unit.equalsIgnoreCase("G")) {
        multiply = t.multiply(new BigDecimal("1073741824"));
    }

    return String.valueOf(multiply.doubleValue());
}

From source file:com.arya.latihan.controller.ItemControllerTest.java

@Test
public void testSave() {
    Item item = new Item();
    item.setName("Biskuit Cokelat");
    item.setPrice(new BigDecimal("5000"));
    item.setCost(new BigDecimal("4500"));
    item.setStock(new BigDecimal("25"));
    item.setExpiredDate(new DateTime(2017, 02, 10, 0, 0));

    RestAssured.given().auth().basic(username, password).contentType("application/json").body(item).log()
            .everything().when().post(url).then().statusCode(201).log().everything()
            .header("Location", Matchers.containsString(url));
}