List of usage examples for java.text NumberFormat getInstance
public static final NumberFormat getInstance()
From source file:com.alibaba.druid.benckmark.pool.Case0.java
private void p0(DataSource dataSource, String name) throws SQLException { long startMillis = System.currentTimeMillis(); long startYGC = TestUtil.getYoungGC(); long startFullGC = TestUtil.getFullGC(); for (int i = 0; i < COUNT; ++i) { Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement(); // ResultSet rs = stmt.executeQuery("SELECT 1"); // rs.close(); // stmt.close(); conn.close();/* ww w. j a va 2 s. co m*/ } long millis = System.currentTimeMillis() - startMillis; long ygc = TestUtil.getYoungGC() - startYGC; long fullGC = TestUtil.getFullGC() - startFullGC; System.out.println(name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC); }
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 {/* w w w. j av a 2s . c o m*/ 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.squale.squaleweb.util.graph.RepartitionMaker.java
/** * @param pValues les valeurs// ww w.j a v a 2 s .co m */ public void build(double[] pValues) { // on ne veut pas de la derniere valeur, car ce sont les lments non nots // on s'arrete sur l'avant avant derniere car pour la derniere colonne // du graph on fait un cumul des 2 dernieres notes mMaxValue = pValues[0]; int value = (int) pValues[0]; double min = 0.0; NumberFormat format = NumberFormat.getInstance(); format.setMaximumFractionDigits(1); final double pas = 0.1; for (int i = 0; i < NB_SERIES_FOR_FLOAT_GRAPH; i++) { if (i == (NB_SERIES_FOR_FLOAT_GRAPH - 1)) { value = (int) (pValues[NB_SERIES_FOR_FLOAT_GRAPH - 1] + pValues[NB_SERIES_FOR_FLOAT_GRAPH]); } else { value = (int) pValues[i]; } // positionne le max if (mMaxValue < value) { mMaxValue = value; } if (value == 0) { mDataSet.addValue(null, new String(format.format(min)), ""); } else { mDataSet.addValue(value, new String(format.format(min)), ""); } min += pas; } }
From source file:gov.nih.nci.cabig.caaers.web.ae.CreateReportingPeriodController.java
@Override protected void initBinder(final HttpServletRequest request, final ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); binder.registerCustomEditor(Integer.class, new CustomNumberEditor(Integer.class, NumberFormat.getInstance(), true)); ControllerTools.registerDomainObjectEditor(binder, epochDao); ControllerTools.registerDomainObjectEditor(binder, treatmentAssignmentDao); }
From source file:com.SCI.centraltoko.utility.UtilityTools.java
public static BigDecimal parseNumberToBigDecimal(String text) { if (!StringUtils.hasText(text)) return BigDecimal.ZERO; try {//from w ww.j ava 2 s . co m BigDecimal number = new BigDecimal(NumberFormat.getInstance().parse(text).doubleValue()); return number; } catch (ParseException ex) { if (Locale.US == Locale.getDefault()) { JOptionPane.showMessageDialog(null, "Region setting anda menggunakan US, pemisah ribuan adalah .(titik) dan pemisah pecahan ada;ah ,(koma) "); } else if (Locale.getDefault().getCountry().equalsIgnoreCase("INDONESIA") && Locale.getDefault().getLanguage().equalsIgnoreCase("ID")) { JOptionPane.showMessageDialog(null, "Region setting anda menggunakan Indonesia, pemisah ribuan adalah ,(koma) dan pemisah pecahan adalah .(titik)"); } } return null; }
From source file:uk.ac.gda.dls.client.views.MonitorCompositeFactory.java
void setVal(String newVal) { if (decimalPlaces != null) { Scanner sc = new Scanner(newVal.trim()); if (sc.hasNextDouble()) { NumberFormat format = NumberFormat.getInstance(); format.setMaximumFractionDigits(decimalPlaces.intValue()); newVal = format.format(sc.nextDouble()); }/*ww w. ja va2 s . c o m*/ sc.close(); } val = newVal; if (!isDisposed()) display.asyncExec(setTextRunnable); }
From source file:com.alibaba.druid.benckmark.pool.Oracle_Case4.java
private void p0(final DataSource dataSource, String name, int threadCount) throws Exception { final CountDownLatch startLatch = new CountDownLatch(1); final CountDownLatch endLatch = new CountDownLatch(threadCount); for (int i = 0; i < threadCount; ++i) { Thread thread = new Thread() { public void run() { try { startLatch.await();// w w w. j av a 2 s. c o m for (int i = 0; i < LOOP_COUNT; ++i) { Connection conn = dataSource.getConnection(); int mod = i % 500; String sql = SQL; // + " AND ROWNUM <= " + (mod + 1); PreparedStatement stmt = conn.prepareStatement(sql); stmt.setInt(1, 61); ResultSet rs = stmt.executeQuery(); int rowCount = 0; while (rs.next()) { rowCount++; } // Assert.isTrue(!rs.isClosed()); rs.close(); // Assert.isTrue(!stmt.isClosed()); stmt.close(); Assert.isTrue(stmt.isClosed()); conn.close(); Assert.isTrue(conn.isClosed()); } } catch (Exception ex) { ex.printStackTrace(); } endLatch.countDown(); } }; thread.start(); } long startMillis = System.currentTimeMillis(); long startYGC = TestUtil.getYoungGC(); long startFullGC = TestUtil.getFullGC(); startLatch.countDown(); endLatch.await(); long millis = System.currentTimeMillis() - startMillis; long ygc = TestUtil.getYoungGC() - startYGC; long fullGC = TestUtil.getFullGC() - startFullGC; System.out.println("thread " + threadCount + " " + name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC); }
From source file:org.jfree.chart.demo.StackedXYAreaChartDemo.java
/** * Creates a chart.//from ww w . java 2 s.c om * * @param dataset the dataset. * * @return A chart. */ private JFreeChart createChart(final TableXYDataset dataset) { final StandardXYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("dd-MMM-yyyy", Locale.UK), NumberFormat.getInstance()); final DateAxis xAxis = new DateAxis("Domain (X)"); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); final NumberAxis yAxis = new NumberAxis("Range (Y)"); yAxis.setAutoRangeIncludesZero(true); final StackedXYAreaRenderer renderer = new StackedXYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES, toolTipGenerator, null); renderer.setOutline(true); renderer.setSeriesPaint(0, new Color(255, 255, 206)); renderer.setSeriesPaint(1, new Color(206, 230, 255)); renderer.setSeriesPaint(2, new Color(255, 230, 230)); renderer.setShapePaint(Color.gray); renderer.setShapeStroke(new BasicStroke(0.5f)); renderer.setShape(new Ellipse2D.Double(-3, -3, 6, 6)); final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true); return chart; }
From source file:uk.ac.lkl.cram.ui.chart.FeedbackChartMaker.java
/** * Create a chart from the provided category dataset * @return a Chart that can be rendered in a ChartPanel */// w w w. ja v a 2s . c o m @Override protected JFreeChart createChart() { //Create a vertical bar chart from the chart factory, with no title, no axis labels, a legend, tooltips but no URLs JFreeChart chart = ChartFactory.createBarChart(null, null, null, (CategoryDataset) dataset, PlotOrientation.VERTICAL, true, true, false); //Get the font from the platform UI Font chartFont = UIManager.getFont("Label.font"); //Get the plot from the chart CategoryPlot plot = (CategoryPlot) chart.getPlot(); //Get the renderer from the plot BarRenderer barRenderer = (BarRenderer) plot.getRenderer(); //Set the rendered to use a standard bar painter (nothing fancy) barRenderer.setBarPainter(new StandardBarPainter()); //Set the colours for the bars barRenderer.setSeriesPaint(0, PEER_ONLY_COLOR); barRenderer.setSeriesPaint(1, TEL_COLOR); barRenderer.setSeriesPaint(2, TUTOR_COLOR); //Set the tooltip to be series, category and value barRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator( "<html><center>{0} ({2} hours)<br/>Double-click for more</center></html>", NumberFormat.getInstance())); //Get the category axis (that's the X-axis in this case) CategoryAxis categoryAxis = plot.getDomainAxis(); //Set the font for rendering the labels on the x-axis to be the platform default categoryAxis.setLabelFont(chartFont); //Hide the tick marks and labels for the x-axis categoryAxis.setTickMarksVisible(false); categoryAxis.setTickLabelsVisible(false); //Set the label for the x-axis categoryAxis.setLabel("Feedback to individuals or group"); //Get the number axis (that's the Y-axis in this case) NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); //Use the same font as the x-axis numberAxis.setLabelFont(chartFont); //Set the label for the vertical axis numberAxis.setLabel("Hours"); return chart; }
From source file:org.davidmendoza.esu.web.EstudiaController.java
@SuppressWarnings("unchecked") @RequestMapping(value = "/popular/{posicion}", method = RequestMethod.GET) @ResponseBody//from w ww . j a va2s . com public Map popular(@PathVariable Integer posicion) throws ParseException { log.info("Populares Estudia({})", posicion); Map resultado = new HashMap(); SimpleDateFormat sdf = new SimpleDateFormat("EEEE", new Locale("es")); Popular popular = publicacionService.obtieneSiguientePopularEstudia(posicion); popular.getPublicacion().getArticulo() .setVistas(publicacionService.agregarVista(popular.getPublicacion().getArticulo())); Trimestre t = trimestreService .obtiene(popular.getPublicacion().getAnio() + popular.getPublicacion().getTrimestre()); if (t != null) { Calendar cal = new GregorianCalendar(Locale.ENGLISH); cal.setTime(t.getInicia()); cal.add(Calendar.SECOND, 1); cal.set(Calendar.DAY_OF_WEEK, obtieneDia(popular.getPublicacion().getDia())); NumberFormat nf = NumberFormat.getInstance(); int weeks = ((Long) nf.parse(popular.getPublicacion().getLeccion().substring(1))).intValue(); if (popular.getPublicacion().getDia().equals("sabado")) { weeks--; } cal.add(Calendar.WEEK_OF_YEAR, weeks); Date hoy = cal.getTime(); resultado.put("dia", hoy); resultado.put("diaString", sdf.format(hoy)); } resultado.put("publicacion", popular.getPublicacion()); resultado.put("posicion", popular.getId()); return resultado; }