List of usage examples for java.math BigDecimal valueOf
public static BigDecimal valueOf(double val)
From source file:com.doctor.ignite.example.spring.SpringIgniteExample.java
public static void main(String[] args) throws InterruptedException { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( SpringIgniteConfig.class); Ignite ignite = applicationContext.getBean(Ignite.class); CacheConfiguration<UUID, Person> cacheConfiguration = applicationContext .getBean("CacheConfigurationForDays", CacheConfiguration.class); IgniteCache<UUID, Person> igniteCache2 = ignite.cache("cacheForDays"); if (igniteCache2 == null) { CacheConfiguration<UUID, Person> cacheConfiguration2 = new CacheConfiguration<>(cacheConfiguration); cacheConfiguration2.setName("cacheForDays"); igniteCache2 = ignite.createCache(cacheConfiguration2); System.out.println("--------createCache:" + "cacheForDays"); }/* w ww .ja va 2 s.c o m*/ Person person = new Person(UUID.randomUUID(), "doctor", BigDecimal.valueOf(88888888.888), "man", "..."); System.out.println(igniteCache2.get(person.getId())); igniteCache2.put(person.getId(), person); System.out.println(igniteCache2.get(person.getId())); TimeUnit.SECONDS.sleep(6); System.out.println(igniteCache2.get(person.getId())); System.out.println(""); Person person1 = new Person(UUID.randomUUID(), "doctor 118", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache2.put(person1.getId(), person1); Person person2 = new Person(UUID.randomUUID(), "doctor who 88 ", BigDecimal.valueOf(188888888.888), "man", "..."); igniteCache2.put(person2.getId(), person2); try (QueryCursor<List<?>> queryCursor = igniteCache2.query(new SqlFieldsQuery("select name from Person"))) { for (List<?> entry : queryCursor) { System.out.println(entry); } } applicationContext.close(); }
From source file:com.super_bits.modulos.paginas.adminTools.PgAdminContainerObjetoTest.java
public static void main(String[] paramentros) { // Ask for user input System.out.print("Enter 1st value:"); // use scanner to read the console input Scanner scan = new Scanner(System.in); String valor = scan.next();/*from w w w . ja v a 2 s.c o m*/ double valorAtualizado = Double.parseDouble(valor) * 8.333; double calculoMultiplo = 10 * (Math.ceil(Math.abs(valorAtualizado / 10))); System.out.println(calculoMultiplo); double teste = (double) Math.round(Double.parseDouble(valor) * 8.3d) * 10 / 10d; System.out.println("TEste:" + teste); System.out.println("Result of the operation is " + valor); System.out.println(Precision.round(0.912385, 0, BigDecimal.ROUND_HALF_UP)); int yourScale = 10; System.out.println(BigDecimal.valueOf(0.42344534534553453453 - 0.42324534524553453453).setScale(yourScale, BigDecimal.ROUND_HALF_UP)); }
From source file:com.test.demo.ccbpay.XLSX2CSV.java
public static void main(String[] args) throws Exception { File f = new File( "C:\\Users\\dmall\\Desktop\\???\\1493142812All2018-05-15_2018-05-20.csv"); InputStreamReader reader = new InputStreamReader(new FileInputStream(f), "GBK"); CSVReader csvReader = new CSVReader(reader); String[] csvRow = null; // row long csvDataSize = 0; long pay0515 = 0L; long re0515 = 0L; long cost0515 = 0L; while ((csvRow = csvReader.readNext()) != null) { if (csvRow.length != 24) { continue; }//from w w w. j a va 2s . c o m csvDataSize += 1; if (csvDataSize > 1) { if (csvRow[0].contains("2018-05-17")) { pay0515 += BigDecimal.valueOf(Double.valueOf(csvRow[12].substring(1, csvRow[12].length()))) .multiply(new BigDecimal(100)).longValue(); re0515 += BigDecimal.valueOf(Double.valueOf(csvRow[16].substring(1, csvRow[16].length()))) .multiply(new BigDecimal(100)).longValue(); cost0515 += BigDecimal.valueOf(Double.valueOf(csvRow[22].substring(1, csvRow[22].length()))) .multiply(new BigDecimal(100)).longValue(); } } } System.out.println(pay0515); System.out.println(re0515); System.out.println(cost0515); System.out.println(pay0515 - re0515 - cost0515); }
From source file:Main.java
public static float divide(int one, int two) { return BigDecimal.valueOf(one).divide(BigDecimal.valueOf(two), 2, BigDecimal.ROUND_HALF_UP).floatValue(); }
From source file:Main.java
public static String long2str(String amount) { return BigDecimal.valueOf(Long.parseLong(amount)).divide(BigDecimal.valueOf(100L)).toString(); }
From source file:Main.java
public static Long decimal2Long(BigDecimal money) { return (money.multiply(BigDecimal.valueOf(100))).longValue(); }
From source file:Main.java
public static double sub(double value1, double value2) { BigDecimal b1 = BigDecimal.valueOf(value1); BigDecimal b2 = BigDecimal.valueOf(value2); return b1.subtract(b2).doubleValue(); }
From source file:Main.java
public static double mul(double value1, double value2) { BigDecimal b1 = BigDecimal.valueOf(value1); BigDecimal b2 = BigDecimal.valueOf(value2); return b1.multiply(b2).doubleValue(); }
From source file:Main.java
private static BigDecimal findRatio(int width, int height) { BigDecimal bdWidth = BigDecimal.valueOf(width); BigDecimal bdHeight = BigDecimal.valueOf(height); return bdWidth.divide(bdHeight, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(1000L)); }
From source file:Main.java
public static int getBigDecimalInt(double value) { return BigDecimal.valueOf(value).setScale(0, RoundingMode.HALF_UP).intValue(); }