List of usage examples for java.lang Double valueOf
@HotSpotIntrinsicCandidate public static Double valueOf(double d)
From source file:com.best.otp.CLegTo.java
String getLegTo() { try {// ww w. ja va 2 s.c o m if (m_legJsonObject != null) { Object legToObject = m_legJsonObject.get("to"); if (legToObject != null) { legToJsonObject = (JSONObject) legToObject; if (legToJsonObject.get("name") != null) LegToName = legToJsonObject.get("name").toString(); if (legToJsonObject.get("geometry") != null) LegToGeometry = legToJsonObject.get("geometry").toString(); String LegToGeometryObject = legToJsonObject.get("geometry").toString(); JSONObject jsonobj = (JSONObject) new JSONParser().parse(LegToGeometryObject); legToStopCode = legToJsonObject.get("stopCode"); legToArrival = legToJsonObject.get("arrival"); legToDeparture = legToJsonObject.get("departure"); legToOrig = legToJsonObject.get("orig"); legToZoneId = legToJsonObject.get("zoneId"); if (legToJsonObject.get("lon") != null) legToLon = Double.valueOf(legToJsonObject.get("lon").toString()); if (legToJsonObject.get("lat") != null) legToLat = Double.valueOf(legToJsonObject.get("lat").toString()); LegToGeometryTypeObject = jsonobj.get("type"); if (LegToGeometryTypeObject != null) LegToGeometryType = (LegToGeometryTypeObject.toString()); LegToGeometrycoordinatesObject = jsonobj.get("coordinates"); if (LegToGeometrycoordinatesObject != null) LegToGeometrycoordinates = (LegToGeometrycoordinatesObject).toString(); System.out.println(LegToGeometryType + " LegToGeometryType"); System.out.println(LegToGeometryPoint + " LegToGeometryPoint"); System.out.println(LegToGeometrycoordinates + " LegToGeometrycoordinate"); legToStopId = new CLegToStopId(legToJsonObject); legToStopId.getlegToStopId(); } } } catch (Exception e) { System.out.println(e); } return (LegToName); }
From source file:com.yahoo.platform.yuitest.coverage.results.DirectoryCoverageReport.java
/** * Returns the percentage of lines called. * @return The percentage of lines called. * @throws org.json.JSONException//from w w w .j av a 2 s . c om */ public double getCalledLinePercentage() throws JSONException { DecimalFormat twoDForm = new DecimalFormat("#.##"); return Double .valueOf(twoDForm.format(((double) getCalledLineCount() / (double) getCoveredLineCount()) * 100)); }
From source file:de.hybris.platform.webservices.PriceResourceTest.java
/** * tax value = (rate * value)/ 1 + rate where rate 1/10 means 10 percent returnig rounded value to *///from ww w. j av a 2 s . co m int getNettoValue(final double valueBrutto, final double taxlevel) { final double taxRate = taxlevel / 100d; return Double.valueOf(valueBrutto - (valueBrutto * taxRate) / (1 + taxRate)).intValue(); //NOPMD }
From source file:com.nubits.nubot.pricefeeds.feedservices.BitstampPriceFeed.java
@Override public LastPrice getLastPrice(CurrencyPair pair) { long now = System.currentTimeMillis(); long diff = now - lastRequest; if (diff >= refreshMinTime) { String url = "https://www.bitstamp.net/api/ticker/"; String htmlString;// w w w . j ava 2 s . com try { htmlString = Utils.getHTML(url, true); } catch (IOException ex) { LOG.error(ex.toString()); return new LastPrice(true, name, pair.getOrderCurrency(), null); } JSONParser parser = new JSONParser(); try { JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString)); double last = Double.valueOf((String) httpAnswerJson.get("last")); //Make the average between buy and sell last = Utils.round(last, 8); lastRequest = System.currentTimeMillis(); lastPrice = new LastPrice(false, name, pair.getOrderCurrency(), new Amount(last, pair.getPaymentCurrency())); return lastPrice; } catch (Exception ex) { LOG.error(ex.toString()); lastRequest = System.currentTimeMillis(); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } else { LOG.warn("Wait " + (refreshMinTime - (System.currentTimeMillis() - lastRequest)) + " ms " + "before making a new request. Now returning the last saved price\n\n"); return lastPrice; } }
From source file:com.nubits.nubot.pricefeeds.feedservices.BitfinexPriceFeed.java
@Override public LastPrice getLastPrice(CurrencyPair pair) { long now = System.currentTimeMillis(); long diff = now - lastRequest; if (diff >= refreshMinTime) { String url = "https://api.bitfinex.com/v1/pubticker/btcusd"; String htmlString;//from w w w .jav a2s .c o m try { htmlString = Utils.getHTML(url, true); } catch (IOException ex) { LOG.error(ex.toString()); return new LastPrice(true, name, pair.getOrderCurrency(), null); } JSONParser parser = new JSONParser(); try { JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString)); double last = Double.valueOf((String) httpAnswerJson.get("last_price")); //Make the average between buy and sell last = Utils.round(last, 8); lastRequest = System.currentTimeMillis(); lastPrice = new LastPrice(false, name, pair.getOrderCurrency(), new Amount(last, pair.getPaymentCurrency())); return lastPrice; } catch (Exception ex) { LOG.error(ex.toString()); lastRequest = System.currentTimeMillis(); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } else { LOG.warn("Wait " + (refreshMinTime - (System.currentTimeMillis() - lastRequest)) + " ms " + "before making a new request. Now returning the last saved price\n\n"); return lastPrice; } }
From source file:com.nebhale.cyclinglibrary.web.PointControllerTest.java
@Test public void readJson() { List<Point> points = Arrays.asList(new Point(Double.valueOf(0), Double.valueOf(1), Double.valueOf(2))); Item item = new Item(Long.valueOf(0), Long.valueOf(1), Long.valueOf(2), "test-name", "test-short-name", points);/*from w w w. j ava2 s .c o m*/ when(this.itemRepository.read(Long.valueOf(2))).thenReturn(item); List<Point> result = this.controller.read(Long.valueOf(2)); assertSame(points, result); }
From source file:com.nubits.nubot.pricefeeds.feedservices.BitstampEURPriceFeed.java
@Override public LastPrice getLastPrice(CurrencyPair pair) { long now = System.currentTimeMillis(); long diff = now - lastRequest; if (diff >= refreshMinTime) { String url = "https://www.bitstamp.net/api/eur_usd/"; String htmlString;//www. j av a 2s . co m try { htmlString = Utils.getHTML(url, true); } catch (IOException ex) { LOG.error(ex.toString()); return new LastPrice(true, name, pair.getOrderCurrency(), null); } JSONParser parser = new JSONParser(); try { JSONObject httpAnswerJson = (JSONObject) (parser.parse(htmlString)); double buy = Double.valueOf((String) httpAnswerJson.get("buy")); double sell = Double.valueOf((String) httpAnswerJson.get("sell")); //Make the average between buy and sell double last = Utils.round((buy + sell) / 2, 8); lastRequest = System.currentTimeMillis(); lastPrice = new LastPrice(false, name, pair.getOrderCurrency(), new Amount(last, pair.getPaymentCurrency())); return lastPrice; } catch (Exception ex) { LOG.error(ex.toString()); lastRequest = System.currentTimeMillis(); return new LastPrice(true, name, pair.getOrderCurrency(), null); } } else { LOG.warn("Wait " + (refreshMinTime - (System.currentTimeMillis() - lastRequest)) + " ms " + "before making a new request. Now returning the last saved price\n\n"); return lastPrice; } }
From source file:com.nts.alphamale.data.EventLog.java
public EventLog(String eventLog) { String[] evLog = StringUtils.split(eventLog, " "); cpuTimestamp = Double.valueOf(StringUtils.split(evLog[1], "]")[0]); curTimeStamp = System.currentTimeMillis(); deviceName = evLog[2];//w w w.j a va 2 s .com evSynOrAbs = evLog[3]; absLabel = evLog[4]; try { absValue = !evLog[5].equals("ffffffff") ? Integer.valueOf(evLog[5], 16) : Integer.MAX_VALUE; } catch (NumberFormatException e) { if (evLog[5].equalsIgnoreCase("down")) { absValue = Integer.MIN_VALUE; } if (evLog[5].equalsIgnoreCase("up")) { absValue = Integer.MAX_VALUE; } } }
From source file:demo.model.ServiceLocationTests.java
@Test public void testServiceLocationSerialization() throws JsonParseException, JsonMappingException, IOException { final ServiceLocation serviceLocation = new ServiceLocation(Double.valueOf(38.907773), Double.valueOf(-77.023735)); serviceLocation.setId("55e521c430044aedf761fa52"); serviceLocation.setAddress1("1317 9th St NW"); serviceLocation.setCity("Washington"); serviceLocation.setState("DC"); serviceLocation.setZip("20001"); serviceLocation.setType("Service"); final InputStream is = ServiceLocationTests.class.getResourceAsStream("/service-location.json"); final String serviceLocationAsString = IOUtils.toString(is); final ObjectMapper objectMapper = new ObjectMapper(); final String json = objectMapper.writeValueAsString(serviceLocation); Assert.assertEquals(serviceLocationAsString, json); }
From source file:pwm.visualizer.MDPPolicyPanel.java
public void updateData(MDPPolicy policy, PWMParticipantInfo participant) { Map<String, StateActionTuple> stateActionTuples = policy.getStateActionTuples(); for (int w = participant.getInitialWeight(); w >= participant.getTargetWeight(); w--) { StateActionTuple entry = stateActionTuples.get("" + w); if (entry == null) { continue; }/* w w w .ja va 2 s . c o m*/ State s = entry.getState(); Action a = entry.getAction(); int weight = s.getValue(); String actionName = a.getName(); if (actionName == null) { continue; } String tokens[] = actionName.split("-"); double calories = Double.valueOf(tokens[0]); double pa = Double.valueOf(tokens[1]); nutritionDataSet.addValue(calories, "Nutrition", "" + weight); nutritionDataSet.addValue(null, "Dummy 1", "" + weight); exerciseDataSet.addValue(null, "Dummy 2", "" + weight); exerciseDataSet.addValue(pa, "PA", "" + weight); } }