List of usage examples for java.text NumberFormat setMinimumFractionDigits
public void setMinimumFractionDigits(int newValue)
From source file:LabelXYToolTipGenerator.java
private String format(double num, int minDecimalPlaces, int maxDecimalPlaces) { NumberFormat format = NumberFormat.getInstance(); format.setMinimumFractionDigits(minDecimalPlaces); format.setMaximumFractionDigits(maxDecimalPlaces); return (format.format(num)); }
From source file:com.skilrock.lms.web.scratchService.orderMgmt.common.BOOrderProcessAction.java
public List<Double> getAgtCreditDetails() throws Exception { PrintWriter out = getResponse().getWriter(); GameDetailsHelper gameHelper = new GameDetailsHelper(); List<Double> accountList = null; try {//from w w w .j a va2s . c om accountList = gameHelper.fetchBOAgentAccDetail(getAgtOrgName()); } catch (LMSException e) { System.out.println("In boOrderProcessAction get Credit details"); e.printStackTrace(); } HttpSession session = getRequest().getSession(); double creditrLimit = 0.0; double currentCrLimit = 0.0; double availableLimit = 0.0; if (accountList != null) { System.out.println("acountlist not null"); creditrLimit = accountList.get(0); currentCrLimit = accountList.get(1); availableLimit = accountList.get(2); session.setAttribute("CRLIMIT", currentCrLimit); session.setAttribute("CURRBAL", availableLimit); // session.setAttribute("CURRBAL",currentBalance); } // changed by yogesh to display available limit on jsp page(without E // type value) NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); String availableCreditTodisplay = nf.format(availableLimit).replace(",", ""); System.out.println("available credit as string#######################3 " + availableCreditTodisplay); String html = "<tr><td><font color='red'> Order Cannot be Dispatched ! Available Credit Amount of '" + getAgtOrgName() + "' is Insufficient </font> </td><td><br><font color='red'>Available Credit Amount is :</font><input type='text' readonly='true' name='crBal' id='crBal' value='" + availableCreditTodisplay + "'/></td></tr>"; System.out.println(html + "99999999999"); response.setContentType("text/html"); out.print(html); System.out.println("crredit amount" + currentCrLimit + "avalaible credit" + availableLimit); return null; }
From source file:io.pcp.parfait.benchmark.StandardMetricThroughPutBenchmark.java
private void report(boolean startPcp, List<MonitoredCounter> counters, long timeTaken, List<CounterIncrementer> counterIncrementers) { long totalBlockedCount = computeTotalBlockedCount( transformToListOfBlockedMetricCollectors(counterIncrementers)); long totalBlockedTime = computeTotalBlockedTime( transformToListOfBlockedMetricCollectors(counterIncrementers)); double counterIncrements = computeTotalCounterIncrements(counters); double incrementRate = counterIncrements / ((double) timeTaken / 1000); NumberFormat numberFormat = NumberFormat.getNumberInstance(); numberFormat.setGroupingUsed(true);/* ww w.jav a 2s. c o m*/ numberFormat.setMaximumFractionDigits(2); numberFormat.setMinimumFractionDigits(2); String incrementRateString = StringUtils.leftPad(numberFormat.format(incrementRate), 15); System.out.printf( "pcpStarted: %s\tperMetricLock: %s\tincrementRate(/sec): %s\t blockedCount: %d\t blockedTime: %d\n", startPcp, usePerMetricLock, incrementRateString, totalBlockedCount, totalBlockedTime); }
From source file:org.sonar.core.i18n.DefaultI18n.java
@Override public String formatDouble(Locale locale, Double value) { NumberFormat format = DecimalFormat.getNumberInstance(locale); format.setMinimumFractionDigits(1); format.setMaximumFractionDigits(1);//from w w w . j a v a 2 s . co m return format.format(value); }
From source file:org.apache.hadoop.hive.ql.udf.UDFNumberFormat.java
public String evaluate(DoubleWritable d, IntWritable fracMax, IntWritable fracMin, IntWritable intMax, IntWritable intMin) {/*from w w w. j av a 2 s . c om*/ if (d == null || fracMax == null || intMax == null) { return null; } if (fracMin == null || intMin == null) { return null; } double ori = d.get(); try { NumberFormat nFormat = NumberFormat.getNumberInstance(); nFormat.setMaximumFractionDigits(fracMax.get()); nFormat.setMaximumIntegerDigits(intMax.get()); nFormat.setMinimumFractionDigits(fracMin.get()); nFormat.setMinimumIntegerDigits(intMin.get()); nFormat.setGroupingUsed(false); return nFormat.format(ori); } catch (Exception e) { LOG.error("can not format value: " + ori); return null; } }
From source file:org.apache.hadoop.hive.ql.udf.UDFNumberFormat.java
public String evaluate(LongWritable d, IntWritable fracMax, IntWritable fracMin, IntWritable intMax, IntWritable intMin) {/*from ww w .j ava2s . c o m*/ if (d == null || fracMax == null || intMax == null) { return null; } if (fracMin == null || intMin == null) { return null; } long ori = d.get(); try { NumberFormat nFormat = NumberFormat.getNumberInstance(); nFormat.setMaximumFractionDigits(fracMax.get()); nFormat.setMaximumIntegerDigits(intMax.get()); nFormat.setMinimumFractionDigits(fracMin.get()); nFormat.setMinimumIntegerDigits(intMin.get()); nFormat.setGroupingUsed(false); return nFormat.format(ori); } catch (Exception e) { LOG.error("can not format value: " + ori); return null; } }
From source file:com.erudika.para.i18n.CurrencyUtils.java
/** * Formats a price for its specific locale, depending on the currency code * @param price the amount//from w w w. j av a2s.c o m * @param cur the 3-letter currency code * @return a formatted price with its currency symbol */ public String formatPrice(Double price, String cur) { String formatted = ""; if (price != null) { Locale locale = CURRENCY_TO_LOCALE_MAP.get(cur); NumberFormat f = (locale == null) ? NumberFormat.getCurrencyInstance(Locale.US) : NumberFormat.getCurrencyInstance(locale); f.setMinimumFractionDigits(2); formatted = f.format(price); } return formatted; }
From source file:net.kjmaster.cookiemom.summary.SummarySalesFragment.java
@AfterViews void afterViews() { List<CookieTransactions> list = Main.daoSession.getCookieTransactionsDao().loadAll(); int total = 0; Double totalCash = 0.0;//from ww w.ja v a 2s . c o m int totalScout = 0; int totalBooth = 0; Double totalScoutCash = 0.0; Double totalBoothCash = 0.0; final HashMap<String, Integer> hashMap = new HashMap<String, Integer>(); for (CookieTransactions cookieTransactions : list) { totalCash += cookieTransactions.getTransCash(); if (cookieTransactions.getTransBoothId() >= 0) { totalBooth += (cookieTransactions.getTransBoxes()); totalBoothCash += cookieTransactions.getTransCash(); } else { if (cookieTransactions.getTransScoutId() >= 0) { totalScout += (cookieTransactions.getTransBoxes()); totalScoutCash += cookieTransactions.getTransCash(); } else { total += cookieTransactions.getTransBoxes(); } } } NumberFormat fmt = NumberFormat.getCurrencyInstance(); fmt.setMaximumFractionDigits(0); fmt.setMinimumFractionDigits(0); ArrayList<Bar> points = new ArrayList<Bar>(); Bar d = new Bar(); d.setColor(getResources().getColor(R.color.bar_due)); d.setName("Due"); d.setValue(total * 4); hashMap.put("Due", total); d.setValueString(fmt.format(total * 4)); Bar d2 = new Bar(); d2.setColor(getResources().getColor(R.color.bar_cash)); d2.setName("Cash"); d2.setValue(totalCash.floatValue()); d2.setValueString(fmt.format(totalCash)); hashMap.put("Cash", (totalBooth + totalScout) * -1); // Bar d3=new Bar(); // d3.setColor(Color.parseColor("#99CC00")); // d3.setName("Booths"); // d3.setValue(totalBooth*-4); // d3.setValueString(fmt.format(totalBooth*4)); Bar d4 = new Bar(); d4.setColor(getResources().getColor(R.color.bar_booth)); d4.setName("Booths"); d4.setValue(totalBoothCash.floatValue()); d4.setValueString(fmt.format(totalBoothCash)); hashMap.put("Booths", totalBooth * -1); // Bar d5=new Bar(); // d5.setColor(Color.parseColor("#99CC00")); // d5.setName("Scouts"); // d5.setValue(totalScout*-4); // d5.setValueString(fmt.format(totalScout*4)); Bar d6 = new Bar(); d6.setColor(getResources().getColor(R.color.bar_scout)); d6.setName("Scouts"); d6.setValue(totalScoutCash.floatValue()); d6.setValueString(fmt.format(totalScoutCash)); hashMap.put("Scouts", totalScout * -1); points.add(d); points.add(d2); //points.add(d3); points.add(d4); // points.add(d5); points.add(d6); BarGraph g = barGraph; g.setBars(points); g.setOnBarClickedListener(new BarGraph.OnBarClickedListener() { @Override public void onClick(int index) { legend.setText(hashMap.get(barGraph.getBars().get(index).getName()).toString() + " bxs."); } }); }
From source file:com.skilrock.lms.web.scratchService.orderMgmt.common.AgentOrderProcessAction.java
public List<Double> getRetCreditDetails() throws Exception { System.out.println("hellllloooooooo"); PrintWriter out = getResponse().getWriter(); GameDetailsHelper gameHelper = new GameDetailsHelper(); List<Double> accountList = null; try {//from w ww.j a v a2s .c om accountList = gameHelper.fetchAgentRetailerAccDetail(getRetOrgName()); } catch (LMSException e) { System.out.println("In boOrderProcessAction get Credit details"); e.printStackTrace(); } HttpSession session = getRequest().getSession(); double creditrLimit = 0.0; double currentCrLimit = 0.0; double availableLimit = 0.0; if (accountList != null) { System.out.println("acountlist not null"); creditrLimit = accountList.get(0); currentCrLimit = accountList.get(1); availableLimit = accountList.get(2); session.setAttribute("RETCRLIMIT", roundTo2DecimalPlaces(currentCrLimit)); session.setAttribute("RETCURRBAL", roundTo2DecimalPlaces(availableLimit)); // session.setAttribute("RETAVAILBAL",availableBalance); } NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); String availableLimitToDisplay = nf.format(availableLimit).replace(",", ""); String html = "<tr><td><font color='red'> Order Cannot be Dispatched ! Available Credit Amount of '" + getRetOrgName() + "' is Insufficient </font> </td><td><br><font color='red'>Available Credit Amount is :</font><input type='text' readonly='true' name='crBal' id='crBal' value='" + availableLimitToDisplay + "'/></td></tr>"; System.out.println(html + "99999999999"); response.setContentType("text/html"); out.print(html); System.out.println("crredit amount" + currentCrLimit + "avalaible credit" + availableLimit); return null; }
From source file:org.apache.flex.utilities.converter.flash.FlashConverter.java
/** * This method generates those artifacts that resemble the framework part of the Flash SDK. * * @throws ConverterException//from w ww. j a v a 2 s . c o m */ protected void generateFrameworkArtifacts() throws ConverterException { // Create a list of all libs that should belong to the Flash SDK runtime. final File directory = new File(rootSourceDirectory, "frameworks.libs.player".replace(".", File.separator)); if (!directory.exists() || !directory.isDirectory()) { throw new ConverterException("Runtime directory does not exist."); } final List<File> playerVersions = new ArrayList<File>(); final File[] versions = directory.listFiles(); if ((versions != null) && (versions.length > 0)) { playerVersions.addAll(Arrays.asList(versions)); // Generate artifacts for every jar in the input directories. for (final File versionDir : playerVersions) { final File playerglobalSwc = new File(versionDir, "playerglobal.swc"); // Convert any version into a two-segment version number. final double playerVersion = Double.valueOf(versionDir.getName()); final NumberFormat doubleFormat = NumberFormat.getInstance(Locale.US); doubleFormat.setMinimumFractionDigits(1); doubleFormat.setMaximumFractionDigits(1); final String version = doubleFormat.format(playerVersion); // Create an artifact for the player-global. final MavenArtifact playerglobal = new MavenArtifact(); playerglobal.setGroupId("com.adobe.flash.framework"); playerglobal.setArtifactId("playerglobal"); playerglobal.setVersion(version); playerglobal.setPackaging("swc"); playerglobal.addDefaultBinaryArtifact(playerglobalSwc); writeArtifact(playerglobal); } } }