List of usage examples for java.lang Double toString
public static String toString(double d)
From source file:io.codis.nedis.util.NedisUtils.java
public static byte[] toBytes(double value) { return toBytes(Double.toString(value)); }
From source file:attask.engine.ResponseInterpreter.java
public static HourBean getTimesheetTaskHours(ClientResponse response) { HourBean hour = new HourBean(); JSONObject obj = new JSONObject(response.getEntity(String.class)); try {//from ww w . j av a 2s .c om String hours = Double.toString((Double) obj.getJSONArray("data").getJSONObject(0).get("hours")); HourBean incomingHr = new HourBean(); incomingHr.convertData(hours); return incomingHr; } catch (Exception ex) { System.out.println(ex.getMessage()); return null; } }
From source file:Main.java
public static String formatDS(double d) { String s = Double.toString(d); int l = s.length(); if (s.startsWith(".0", l - 2)) return s.substring(0, l - 2); int skip = l - 16; int e = s.indexOf('E', l - 5); return e < 0 ? (skip > 0 ? s.substring(0, 16) : s) : s.startsWith(".0", e - 2) ? cut(s, e - 2, e) : skip > 0 ? cut(s, e - skip, e) : s; }
From source file:Main.java
static void generateXMLIntervalSampleCoarse(double time, long tracks, String hardware, boolean finalStats) { Element element;/* w ww. java2 s. c o m*/ Element root = doc.getDocumentElement(); Element me; if (finalStats) me = doc.createElement("FinalSample"); else me = doc.createElement("Sample"); root.appendChild(me); root = me; element = doc.createElement("Timestamp"); element.setTextContent(Double.toString(time)); root.appendChild(element); element = doc.createElement("Hardware"); element.setTextContent(hardware); root.appendChild(element); // if (transactions > 0) { element = doc.createElement("DataAvailable"); element.setTextContent("True"); root.appendChild(element); element = doc.createElement("LaidTracks"); element.setTextContent(Long.toString(tracks)); root.appendChild(element); }
From source file:com.espe.distribuidas.protocolocajero.operaciones.DepositoRS.java
@Override public String asTexto() { StringBuilder sb = new StringBuilder(); sb.append(this.resultado); if (this.resultado.equals(DepositoRS.DEPOSITO_EXITOSO)) { sb.append(StringUtils.leftPad(Double.toString(this.saldoActual), 10, "0")); }//from w w w . jav a2 s . co m return sb.toString(); }
From source file:kr.ac.kaist.se.simulator.NormalDistributor.java
public int getNextVal() { String _val = Double.toString(this.distGenerator.sample()); BigDecimal dec = new BigDecimal(_val); BigDecimal std = new BigDecimal(Integer.toString(this.stDev)); dec = dec.add(new BigDecimal(Integer.toString(mean))); std = std.multiply(new BigDecimal(_val)); int retVal = dec.add(std).toBigInteger().intValue(); return retVal; }
From source file:com.cloudera.oryx.app.batch.mllib.kmeans.RandomKMeansDataGenerator.java
@Override public Pair<String, String> generate(int id, RandomGenerator random) { List<String> elements = new ArrayList<>(numberOfDimensions); for (int i = 0; i < numberOfDimensions; i++) { double d = random.nextDouble(); elements.add(Double.toString(d)); }/*from ww w . ja v a 2 s .c o m*/ return new Pair<>(Integer.toString(id), TextUtils.joinDelimited(elements, ',')); }
From source file:application.ScheduledTasks.java
/** * updates data shown on the display/*from w ww. java 2 s .c om*/ */ @Scheduled(fixedRate = 60000) public void updateTemperature() { CharLCD.clear(); Temperature temp = TemperatureReader.readTemperature(); String text = dateFormat.format(new Date()) + "\n" + "Temp: " + Double.toString(temp.getTemperature()); CharLCD.message(text); }
From source file:Main.java
static void generateXMLIntervalSample(double time, long commits, long transactions, long commitMemRefs, long totalMemRefs, String hardware, boolean finalStats) { Element element;/*from w ww .j a v a2 s . c o m*/ Element root = doc.getDocumentElement(); Element me; if (finalStats) me = doc.createElement("FinalSample"); else me = doc.createElement("Sample"); root.appendChild(me); root = me; element = doc.createElement("Timestamp"); element.setTextContent(Double.toString(time)); root.appendChild(element); element = doc.createElement("Hardware"); element.setTextContent(hardware); root.appendChild(element); // if (transactions > 0) { element = doc.createElement("DataAvailable"); element.setTextContent("True"); root.appendChild(element); element = doc.createElement("Transactions"); element.setTextContent(Long.toString(transactions)); root.appendChild(element); element = doc.createElement("Commits"); element.setTextContent(Long.toString(commits)); root.appendChild(element); String pc; if (commits != 0 && transactions != 0) { pc = Long.toString(100 * commits / transactions); } else { pc = "0"; } element = doc.createElement("PercentCommits"); element.setTextContent(pc); root.appendChild(element); element = doc.createElement("MemRefs"); element.setTextContent(Long.toString(totalMemRefs)); root.appendChild(element); element = doc.createElement("CommitMemRefs"); element.setTextContent(Long.toString(commitMemRefs)); root.appendChild(element); String pm; if (commitMemRefs != 0 && totalMemRefs != 0) { pm = Long.toString(100 * commitMemRefs / totalMemRefs); } else { pm = "0"; } element = doc.createElement("PercentCommitMemRefs"); element.setTextContent(pm); root.appendChild(element); }
From source file:com.espe.distribuidas.protocolocajero.operaciones.RetiroRS.java
@Override public String asTexto() { StringBuilder sb = new StringBuilder(); sb.append(this.resultado); if (this.resultado.equals(DepositoRS.DEPOSITO_EXITOSO)) { sb.append(StringUtils.leftPad(Double.toString(this.saldoActual), 10, "0")); }// ww w. ja v a2 s . c o m return sb.toString(); }