List of usage examples for java.math BigDecimal valueOf
public static BigDecimal valueOf(double val)
From source file:Main.java
public static void main(String[] args) { Long l = new Long("12345678"); BigDecimal bg = BigDecimal.valueOf(l); System.out.println(bg);//from w w w . j ava2 s .c o m }
From source file:Main.java
public static void main(String[] args) { Double d = new Double("123.45678"); BigDecimal bg = BigDecimal.valueOf(d); System.out.println(bg);//from www .j av a 2 s.com }
From source file:Main.java
public static void main(String[] argv) throws Exception { BigDecimal bd1 = new BigDecimal("123456789.0123456890"); // Create via a long BigDecimal bd2 = BigDecimal.valueOf(123L); bd1 = bd1.subtract(bd2);//from w w w.ja va 2 s .c om }
From source file:Main.java
public static void main(String[] argv) throws Exception { BigDecimal bd1 = new BigDecimal("123456789.0123456890"); // Create via a long BigDecimal bd2 = BigDecimal.valueOf(123L); bd1 = bd1.divide(bd2, BigDecimal.ROUND_UP); }
From source file:Main.java
public static void main(String[] argv) throws Exception { BigDecimal bd1 = new BigDecimal("123456789.0123456890"); // Create via a long BigDecimal bd2 = BigDecimal.valueOf(123L); bd1 = bd1.multiply(bd2);/*from w w w .j a va 2s . c o m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Create via a string BigDecimal bd1 = new BigDecimal("123456789.0123456890"); // Create via a long BigDecimal bd2 = BigDecimal.valueOf(123L); bd1 = bd1.add(bd2);//from w w w . ja v a2 s .com }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Create via a string BigDecimal bd1 = new BigDecimal("123456789.0123456890"); // Create via a long BigDecimal bd2 = BigDecimal.valueOf(123L); bd1 = bd1.add(bd2);/*w w w. j av a2 s. c om*/ bd1 = bd1.multiply(bd2); bd1 = bd1.subtract(bd2); bd1 = bd1.divide(bd2, BigDecimal.ROUND_UP); bd1 = bd1.negate(); }
From source file:com.enitalk.controllers.paypal.Usd.java
public static void main(String[] args) throws IOException, ParseException { String rs = Request.Get("http://www.cbr.ru/scripts/XML_daily.asp") .addHeader("Content-type", "application/xml;charset=utf-8").execute().returnContent() .asString(Charset.forName("windows-1251")); Pair<AutoPilot, VTDNav> bb = getNavigator(rs.getBytes()); String change = getChange(bb.getLeft(), bb.getRight()); System.out.println("Rs " + change); DecimalFormat df = new DecimalFormat(); DecimalFormatSymbols symbols = new DecimalFormatSymbols(); symbols.setDecimalSeparator(','); df.setDecimalFormatSymbols(symbols); BigDecimal dd = BigDecimal.valueOf(df.parse(change).doubleValue()).setScale(2, RoundingMode.CEILING); System.out.println("Dd " + dd); }
From source file:com.doctor.ignite.example.spring.CrossCacheQueries.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> igniteCache1 = getCache("person1", ignite, cacheConfiguration); Person person = new Person(UUID.randomUUID(), "doctor -1 ", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache1.put(person.getId(), person); Person person1 = new Person(UUID.randomUUID(), "doctor 118", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache1.put(person1.getId(), person1); Person person2 = new Person(UUID.randomUUID(), "doctor who 88 ", BigDecimal.valueOf(188888888.888), "man", "..."); igniteCache1.put(person2.getId(), person2); IgniteCache<UUID, Person> igniteCache2 = getCache("person2", ignite, cacheConfiguration); Person person3 = new Person(UUID.randomUUID(), "doctor who ---88 ", BigDecimal.valueOf(1188888888.888), "man", "..."); igniteCache2.put(person3.getId(), person3); // try (QueryCursor<List<?>> queryCursor = igniteCache1.query(new SqlFieldsQuery("select name from Person"))) { // for (List<?> entry : queryCursor) { // System.out.println("--}}}}}" + entry); // }//from www .ja va 2 s . c o m // } SqlQuery sqlQuery = new SqlQuery<>(Person.class, "from Person , \"person2\".Person "); try (QueryCursor queryCursor = igniteCache1.query(sqlQuery)) { for (Object object : queryCursor) { System.out.println(object); } } applicationContext.close(); }
From source file:com.doctor.ignite.example.spring.SqlUnion.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> igniteCache1 = getCache("person1", ignite, cacheConfiguration); Person person = new Person(UUID.randomUUID(), "doctor -1 ", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache1.put(person.getId(), person); Person person1 = new Person(UUID.randomUUID(), "doctor 118", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache1.put(person1.getId(), person1); Person person2 = new Person(UUID.randomUUID(), "doctor who 88 ", BigDecimal.valueOf(188888888.888), "man", "..."); igniteCache1.put(person2.getId(), person2); IgniteCache<UUID, Person> igniteCache2 = getCache("person2", ignite, cacheConfiguration); Person person3 = new Person(UUID.randomUUID(), "doctor who ---88 ", BigDecimal.valueOf(1188888888.888), "man", "..."); igniteCache2.put(person3.getId(), person3); SqlFieldsQuery sqlFieldsQuery = new SqlFieldsQuery( "select _val from Person union all select _val from \"person2\".Person"); try (QueryCursor queryCursor = igniteCache1.query(sqlFieldsQuery)) { for (Object object : queryCursor) { System.out.println(object); }//from w w w .jav a 2 s . c o m } applicationContext.close(); }