List of usage examples for java.lang Double valueOf
@HotSpotIntrinsicCandidate public static Double valueOf(double d)
From source file:com.brightcove.com.zartan.verifier.video.VideoDurationVerifier.java
@ZartanCheck(value = "The video object has same duration as uploaded file") public ResultEnum assertVideoDurationCorrect(UploadData upData) throws Throwable { int expected = upData.getmIngestFile().getFileInfo().getVideoDuration(); int actual = upData.getHttpResponseJson().get("length").getIntValue(); assertEquals("Duration not within expected bounds", expected, actual, (toleranceFactor * Double.valueOf(expected))); return ResultEnum.PASS; }
From source file:org.grails.datastore.mapping.model.types.BasicTypeConverterRegistrar.java
public void register(ConverterRegistry registry) { registry.addConverter(new Converter<Date, String>() { public String convert(Date date) { return String.valueOf(date.getTime()); }//from w w w . j av a2 s . c o m }); registry.addConverter(new Converter<Date, Calendar>() { public Calendar convert(Date date) { final GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(date); return calendar; } }); registry.addConverter(new Converter<Integer, Long>() { public Long convert(Integer integer) { return integer.longValue(); } }); registry.addConverter(new Converter<Long, Integer>() { public Integer convert(Long longValue) { return longValue.intValue(); } }); registry.addConverter(new Converter<Integer, Double>() { public Double convert(Integer integer) { return integer.doubleValue(); } }); registry.addConverter(new Converter<CharSequence, Date>() { public Date convert(CharSequence s) { try { final Long time = Long.valueOf(s.toString()); return new Date(time); } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } } }); registry.addConverter(new Converter<CharSequence, Double>() { public Double convert(CharSequence s) { try { return Double.valueOf(s.toString()); } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } } }); registry.addConverter(new Converter<CharSequence, Integer>() { public Integer convert(CharSequence s) { try { return Integer.valueOf(s.toString()); } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } } }); registry.addConverter(new Converter<CharSequence, Long>() { public Long convert(CharSequence s) { try { return Long.valueOf(s.toString()); } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } } }); registry.addConverter(new Converter<Object, String>() { public String convert(Object o) { return o.toString(); } }); registry.addConverter(new Converter<Calendar, String>() { public String convert(Calendar calendar) { return String.valueOf(calendar.getTime().getTime()); } }); registry.addConverter(new Converter<CharSequence, Calendar>() { public Calendar convert(CharSequence s) { try { Date date = new Date(Long.valueOf(s.toString())); Calendar c = new GregorianCalendar(); c.setTime(date); return c; } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } } }); }
From source file:com.zhengxuetao.gupiao.service.impl.DayServiceImpl.java
@Override public boolean saveDayDataFromFile(File file) { if (file != null && file.exists() && file.isFile()) { DayData dayData = new DayData(); String fileName = file.getName(); //SH#600004.txt dayData.setFinanceId(Long.parseLong(fileName.substring(3, 9))); String encoding = "GBK"; InputStreamReader reader = null; DateFormat format = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss"); DateFormat parseFormat = new SimpleDateFormat("yyyy-mm-dd"); try {/* w w w. j ava2s .co m*/ reader = new InputStreamReader(new FileInputStream(file), encoding); BufferedReader bufferedReader = new BufferedReader(reader); String readLine; while ((readLine = bufferedReader.readLine()) != null) { //?????????? String[] arr = readLine.split(","); dayData.setTime(Timestamp.valueOf(format.format(parseFormat.parse(arr[0])))); dayData.setStartPrice(Float.valueOf(arr[1])); dayData.setHighPrice(Float.valueOf(arr[2])); dayData.setLowPrice(Float.valueOf(arr[3])); dayData.setEndPrice(Float.valueOf(arr[4])); dayData.setVolume(Long.valueOf(arr[5])); dayData.setAmount(Double.valueOf(arr[6])); userDAO.saveDayData(dayData); } } catch (IOException | ParseException ex) { logger.error(ex.getMessage()); } finally { try { reader.close(); } catch (IOException ex) { logger.error(ex.getMessage()); } } } else { logger.error("?!"); } return true; }
From source file:com.nec.harvest.service.impl.ConsumptionTaxRateServiceImpl.java
/** {@inheritDoc} */ @Override/* w w w . jav a 2 s . c om*/ public Double findRateDefByDate(Calendar date) throws ServiceException { if (date == null) { throw new IllegalArgumentException("Date must not be null"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; double updatedRecordsNo = 0; try { tx = session.beginTransaction(); Query query = repository.getQuery(session, "SELECT a.rateDef FROM ConsumptionTaxRate a " + " WHERE a.enfDate = ( " + " SELECT MAX(b.enfDate) FROM ConsumptionTaxRate b " + " WHERE b.enfDate < ? AND b.delKbn = ? ) "); query.setParameter(0, date); query.setParameter(1, Constants.STATUS_ACTIVE); Object result = query.uniqueResult(); // Release transaction tx.commit(); if (result == null) { throw new ObjectNotFoundException("Can not find tax rate"); } // updatedRecordsNo = Double.valueOf(result.toString()); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("An exception occured while getting rateDef by date " + date, ex); } finally { HibernateSessionManager.closeSession(session); } return updatedRecordsNo; }
From source file:boa.aggregators.ConfidenceIntervalAggregator.java
/** {@inheritDoc} */ @Override// w w w . java 2 s .c o m public void aggregate(final double data, final String metadata) { this.aggregate(Double.valueOf(data).longValue(), metadata); }
From source file:org.physionet.graphics.Plot.java
public static XYDataset createDataset(ArrayList[] data) { //XYDataset result = DatasetUtilities.sampleFunction2D(new X2(), // -4.0, 4.0, 40, "f(x)"); XYSeriesCollection result = new XYSeriesCollection(); XYSeries series = new XYSeries(1); //Insert data into plotting series for (int n = 0; n < data[1].size(); n++) { series.add(Double.valueOf((String) data[0].get(n)), Double.valueOf((String) data[1].get(n))); }/* w ww . j a v a 2 s . co m*/ result.addSeries(series); return result; }
From source file:eu.europa.ec.fisheries.uvms.spatial.rest.resources.secured.GeometryUtilsResource.java
@POST @Consumes(MediaType.APPLICATION_JSON)/*from w ww. ja va2s . c o m*/ @Produces(MediaType.APPLICATION_JSON) @Path("/buffer") public Response buffer(Map<String, Object> payload) { Response response; try { Double latitude = Double.valueOf(String.valueOf(payload.get("latitude"))); Double longitude = Double.valueOf(String.valueOf(payload.get("longitude"))); Double buffer = Double.valueOf(String.valueOf(payload.get("buffer"))); response = createSuccessResponse(service.calculateBuffer(latitude, longitude, buffer)); } catch (Exception ex) { String error = "[ Error when calculating buffer. ] "; log.error(error, ex); response = createErrorResponse(error); } return response; }
From source file:com.tiempometa.muestradatos.TagReading.java
public TagReading(String data) { super();// w w w . j a va 2s.c o m stringData = data; if (data.startsWith("#")) { readingType = TagReading.TYPE_COMMAND_RESPONSE; // command response String[] fields = data.replaceAll("\\r", "").split(","); switch (fields.length) { case 0: break; case 1: break; case 2: break; case 3: System.out.println("Time - " + fields[2]); System.out.println("Time + " + (new Date()).getTime()); Double millis = Double.valueOf(fields[2]) * 1000; time = new Date(millis.longValue()); Long diff = (new Date()).getTime() - time.getTime(); epc = diff.toString(); readingType = TagReading.TYPE_COMMAND_RESPONSE; timeMillis = time.getTime(); break; } } else { readingType = TagReading.TYPE_TAG; String[] fields = data.replaceAll("\\r", "").split(","); switch (fields.length) { case 0: break; case 1: break; case 2: valid = true; // single field data packet is keep alive readingType = TagReading.TYPE_KEEP_ALIVE; antenna = fields[1]; break; case 7: // six field data packet includes user data userData = fields[6]; case 6: tid = fields[5]; case 5: // five field data packet lacks user data valid = true; reader = fields[0]; antenna = fields[1]; epc = fields[2]; try { timeMillis = Long.valueOf(fields[3]); time = new Date(timeMillis / 1000); peakRssi = Integer.parseInt(fields[4]); } catch (NumberFormatException e) { valid = false; } break; default: } } }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.BulletGraph.java
public void configureChart(SourceBean content) { logger.debug("IN"); super.configureChart(content); String target = (String) confParameters.get("target"); if (target != null) this.target = new Double(target); SourceBean confSB = (SourceBean) content.getAttribute("INTERVALS"); if (confSB == null) { confSB = (SourceBean) content.getAttribute("CONF.INTERVALS"); }//from w w w.ja v a2 s .com List confAttrsList = confSB.getAttributeAsList(INTERVAL); if (!confAttrsList.isEmpty()) { Iterator it = confAttrsList.iterator(); while (it.hasNext()) { SourceBean param = (SourceBean) it.next(); KpiInterval interval = new KpiInterval(); String min = (String) param.getAttribute(MIN_INTERVAL); String max = (String) param.getAttribute(MAX_INTERVAL); String col = (String) param.getAttribute(COLOR_INTERVAL); interval.setMin(Double.valueOf(min).doubleValue()); interval.setMax(Double.valueOf(max).doubleValue()); Color color = new Color(Integer.decode(col).intValue()); interval.setColor(color); this.intervals.add(interval); } } logger.debug("OUT"); }
From source file:com.itemanalysis.psychometrics.cfa.MaximumLikelihoodEstimation.java
public double value(double[] argument) { model.setParameters(argument);//from ww w . j av a2 s . c o m // Linesearch method in QNMinimizer is causing NaN values after repeated calls to here // Next libe is for monitoring values when called from line search // No problem occurs with CGMinimizer // System.out.println("valueAt: " + argument[0] + " " + argument[1]); SIGMA = model.getImpliedCovariance(argument); //compute determinant of SIGMA LUDecomposition SLUD = new LUDecomposition(SIGMA); double detSig = SLUD.getDeterminant(); //compute inverse of SIGMA RealMatrix SIGMAinv = SLUD.getSolver().getInverse(); RealMatrix VC_SIGMA_INV = varcov.multiply(SIGMAinv); double trace = VC_SIGMA_INV.getTrace(); //convert number of items to double double p = Double.valueOf(model.getNumberOfItems()).doubleValue(); //compute objective function F = Math.log(detSig) + trace - Math.log(detVc) - p; return F; }