List of usage examples for java.lang Double Double
@Deprecated(since = "9") public Double(String s) throws NumberFormatException
From source file:HtmlDimensions.java
public static Double decode(String size) { // TODO - handle px,ex,pt enc suffixes. double d = 0; try {//from w ww . j av a 2 s. co m if (size != null) { if (PATTERN_NUMERIC.matcher(size).matches()) { synchronized (numericFormat) { d = numericFormat.parse(size).doubleValue(); } } else if (PATTERN_PX.matcher(size).matches()) { synchronized (pxFormat) { d = pxFormat.parse(size).doubleValue(); } } else if (PATTERN_PCT.matcher(size).matches()) { synchronized (pctFormat) { d = pctFormat.parse(size).doubleValue(); } } } } catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); } return new Double(d); }
From source file:com.redhat.lightblue.crud.validator.MinMaxCheckerTest.java
/** * Col1: For debugging purposes to know which test case had issues * Col2: A instantiation to test with. Should always represent 2. *///w ww . j a v a 2 s . c o m @Parameters(name = "{index}: {0}") public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { { Integer.class, new Integer(2) }, { Byte.class, new Byte(new Integer(2).byteValue()) }, { Short.class, new Short(new Integer(2).shortValue()) }, { Long.class, new Long(2L) }, { Float.class, new Float(2F) }, { Double.class, new Double(2D) }, { BigInteger.class, new BigInteger("2") }, { BigDecimal.class, new BigDecimal(2) } }); }
From source file:org.mayocat.configuration.json.ConfigurableTest.java
@Test public void testDeserializeConfigurableDouble() throws Exception { Configurable<Double> value1 = mapper.readValue("{\"default\": 4.20, \"configurable\":false}", Configurable.class); assertEquals(value1.isConfigurable(), false); assertEquals(value1.getDefaultValue(), new Double(4.20)); Configurable<Double> value2 = mapper.readValue("{\"default\": 3.14, \"configurable\":true}", Configurable.class); assertEquals(value2.isConfigurable(), true); assertEquals(value2.getDefaultValue(), new Double(3.14)); }
From source file:io.rhiot.component.gpsd.GpsdHelper.java
/** * Process the TPVObject, all params required. * /*from ww w .j a v a 2s. co m*/ * @param tpv The time-position-velocity object to process * @param processor Processor that handles the exchange. * @param endpoint GpsdEndpoint receiving the exchange. */ public static void consumeTPVObject(TPVObject tpv, Processor processor, GpsdEndpoint endpoint, ExceptionHandler exceptionHandler) { // Simplify logging when https://github.com/taimos/GPSd4Java/pull/19 is merged into upstream. LOG.debug("About to consume TPV object {},{} from {}", tpv.getLatitude(), tpv.getLongitude(), endpoint); Validate.notNull(tpv); Validate.notNull(processor); Validate.notNull(endpoint); GpsCoordinates coordinates = gpsCoordinates(new Date(new Double(tpv.getTimestamp()).longValue()), tpv.getLatitude(), tpv.getLongitude()); Exchange exchange = anExchange(endpoint.getCamelContext()).withPattern(OutOnly).withHeader(TPV_HEADER, tpv) .withBody(coordinates).build(); try { processor.process(exchange); } catch (Exception e) { exceptionHandler.handleException(e); } }
From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.DoubleCalculator.java
public Object div(Object obj1, Object obj2) { Double doubleData1 = (Double) obj1; Double doubleData2 = (Double) obj2; return (Object) (new Double((double) (doubleData1.doubleValue() / doubleData2.doubleValue()))); }
From source file:view.GerarGrafico.java
private PieDataset createDataset(String filtro) { DefaultPieDataset dataset = new DefaultPieDataset(); if (contaTrasacoesDespesasFilstrada(filtro) > 0 && contaTrasacoesProventoFilstrada(filtro) == 0) { dataset.setValue("Despesas", new Double(contaTrasacoesDespesasFilstrada(filtro))); }/*from w ww.java 2 s. c o m*/ else if (contaTrasacoesDespesasFilstrada(filtro) == 0 && contaTrasacoesProventoFilstrada(filtro) > 0) { dataset.setValue("Proventos", new Double(contaTrasacoesProventoFilstrada(filtro))); } else { dataset.setValue("Despesas", new Double(contaTrasacoesDespesasFilstrada(filtro))); dataset.setValue("Proventos", new Double(contaTrasacoesProventoFilstrada(filtro))); } return dataset; }
From source file:NumberFormatDemo.java
static public void displayCurrency(Locale currentLocale) { Double currency = new Double(9876543.21); NumberFormat currencyFormatter; String currencyOut;//from w w w . java 2 s . com currencyFormatter = NumberFormat.getCurrencyInstance(currentLocale); currencyOut = currencyFormatter.format(currency); System.out.println(currencyOut + " " + currentLocale.toString()); }
From source file:cn.edu.thss.iise.bpmdemo.charts.SWTPieChartDemo1.java
/** * Creates a sample dataset./*from ww w . j a v a2 s. c o m*/ * * @return A sample dataset. */ private static PieDataset createDataset() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("One", new Double(43.2)); dataset.setValue("Two", new Double(10.0)); dataset.setValue("Three", new Double(27.5)); dataset.setValue("Four", new Double(17.5)); dataset.setValue("Five", new Double(11.0)); dataset.setValue("Six", new Double(19.4)); return dataset; }
From source file:Main.java
public static Object getNamedElemValue(Element parent, String elementName, Class basicType, Object defaultVal) { String val = getNamedElemValue(parent, elementName); if (val == null) { return defaultVal; }// w w w .j a va2s . co m try { if (Boolean.class.equals(basicType)) { return new Boolean(val); } else if (Integer.class.equals(basicType)) { return new Integer(val); } else if (Float.class.equals(basicType)) { return new Float(val); } else if (Double.class.equals(basicType)) { return new Double(val); } else return val; } catch (Exception e) { return defaultVal; } }
From source file:Main.java
/** * Sums an array of numbers together while using the correct class type. * * @param numbers/*from w w w. ja v a 2s .c o m*/ * * @return the sum contained in the most appropriate number class */ static Number sum(Number[] numbers) { Number newSum = (Number) getObject(numbers); if (newSum == null) { return null; } //Integer, Long, Float, Double if (newSum instanceof Integer) { int sum = 0; int nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].intValue(); sum += nextValue; } newSum = new Integer(sum); } else if (newSum instanceof Long) { long sum = 0; long nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].longValue(); sum += nextValue; } newSum = new Long(sum); } else if (newSum instanceof Float) { float sum = 0; float nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].floatValue(); sum += nextValue; } newSum = new Float(sum); } else if (newSum instanceof Double) { double sum = 0; double nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].doubleValue(); sum += nextValue; } newSum = new Double(sum); } else { return null; } return newSum; }