List of usage examples for java.text NumberFormat setMinimumFractionDigits
public void setMinimumFractionDigits(int newValue)
From source file:net.sourceforge.eclipsetrader.core.internal.XMLRepository.java
private void saveSecurity(Security security, Document document, Element root) { Element element = document.createElement("security"); //$NON-NLS-1$ element.setAttribute("id", String.valueOf(security.getId())); //$NON-NLS-1$ root.appendChild(element);//w w w . j a va2s. c om Element node = document.createElement("code"); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getCode())); element.appendChild(node); node = document.createElement("description"); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getDescription())); element.appendChild(node); if (security.getCurrency() != null) { node = document.createElement("currency"); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getCurrency().getCurrencyCode())); element.appendChild(node); } NumberFormat nf = NumberFormat.getInstance(); nf.setGroupingUsed(false); nf.setMinimumIntegerDigits(2); nf.setMinimumFractionDigits(0); nf.setMaximumFractionDigits(0); Element collectorNode = document.createElement("dataCollector"); //$NON-NLS-1$ collectorNode.setAttribute("enable", String.valueOf(security.isEnableDataCollector())); //$NON-NLS-1$ element.appendChild(collectorNode); node = document.createElement("begin"); //$NON-NLS-1$ node.appendChild(document.createTextNode( nf.format(security.getBeginTime() / 60) + ":" + nf.format(security.getBeginTime() % 60))); //$NON-NLS-1$ collectorNode.appendChild(node); node = document.createElement("end"); //$NON-NLS-1$ node.appendChild(document.createTextNode( nf.format(security.getEndTime() / 60) + ":" + nf.format(security.getEndTime() % 60))); //$NON-NLS-1$ collectorNode.appendChild(node); node = document.createElement("weekdays"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getWeekDays()))); collectorNode.appendChild(node); node = document.createElement("keepdays"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getKeepDays()))); collectorNode.appendChild(node); if (security.getQuoteFeed() != null || security.getLevel2Feed() != null || security.getHistoryFeed() != null) { Node feedsNode = document.createElement("feeds"); //$NON-NLS-1$ element.appendChild(feedsNode); if (security.getQuoteFeed() != null) { node = document.createElement("quote"); //$NON-NLS-1$ node.setAttribute("id", security.getQuoteFeed().getId()); //$NON-NLS-1$ if (security.getQuoteFeed().getExchange() != null) node.setAttribute("exchange", security.getQuoteFeed().getExchange()); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getQuoteFeed().getSymbol())); feedsNode.appendChild(node); } if (security.getLevel2Feed() != null) { node = document.createElement("level2"); //$NON-NLS-1$ node.setAttribute("id", security.getLevel2Feed().getId()); //$NON-NLS-1$ if (security.getLevel2Feed().getExchange() != null) node.setAttribute("exchange", security.getLevel2Feed().getExchange()); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getLevel2Feed().getSymbol())); feedsNode.appendChild(node); } if (security.getHistoryFeed() != null) { node = document.createElement("history"); //$NON-NLS-1$ node.setAttribute("id", security.getHistoryFeed().getId()); //$NON-NLS-1$ if (security.getHistoryFeed().getExchange() != null) node.setAttribute("exchange", security.getHistoryFeed().getExchange()); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getHistoryFeed().getSymbol())); feedsNode.appendChild(node); } } if (security.getTradeSource() != null) { TradeSource source = security.getTradeSource(); Element feedsNode = document.createElement("tradeSource"); //$NON-NLS-1$ feedsNode.setAttribute("id", source.getTradingProviderId()); //$NON-NLS-1$ if (source.getExchange() != null) feedsNode.setAttribute("exchange", source.getExchange()); //$NON-NLS-1$ element.appendChild(feedsNode); if (!source.getSymbol().equals("")) //$NON-NLS-1$ { node = document.createElement("symbol"); //$NON-NLS-1$ node.appendChild(document.createTextNode(source.getSymbol())); feedsNode.appendChild(node); } if (source.getAccountId() != null) { node = document.createElement("account"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(source.getAccountId()))); feedsNode.appendChild(node); } node = document.createElement("quantity"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(source.getQuantity()))); feedsNode.appendChild(node); } if (security.getQuote() != null) { Quote quote = security.getQuote(); Node quoteNode = document.createElement("quote"); //$NON-NLS-1$ if (quote.getDate() != null) { node = document.createElement("date"); //$NON-NLS-1$ node.appendChild(document.createTextNode(dateTimeFormat.format(quote.getDate()))); quoteNode.appendChild(node); } node = document.createElement("last"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getLast()))); quoteNode.appendChild(node); node = document.createElement("bid"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getBid()))); quoteNode.appendChild(node); node = document.createElement("ask"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getAsk()))); quoteNode.appendChild(node); node = document.createElement("bidSize"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getBidSize()))); quoteNode.appendChild(node); node = document.createElement("askSize"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getAskSize()))); quoteNode.appendChild(node); node = document.createElement("volume"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getVolume()))); quoteNode.appendChild(node); element.appendChild(quoteNode); } Node dataNode = document.createElement("data"); //$NON-NLS-1$ element.appendChild(dataNode); if (security.getOpen() != null) { node = document.createElement("open"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getOpen()))); dataNode.appendChild(node); } if (security.getHigh() != null) { node = document.createElement("high"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getHigh()))); dataNode.appendChild(node); } if (security.getLow() != null) { node = document.createElement("low"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getLow()))); dataNode.appendChild(node); } if (security.getClose() != null) { node = document.createElement("close"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getClose()))); dataNode.appendChild(node); } node = document.createElement("comment"); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getComment())); element.appendChild(node); for (Iterator iter = security.getSplits().iterator(); iter.hasNext();) { Split split = (Split) iter.next(); node = document.createElement("split"); //$NON-NLS-1$ node.setAttribute("date", dateTimeFormat.format(split.getDate())); //$NON-NLS-1$ node.setAttribute("fromQuantity", String.valueOf(split.getFromQuantity())); //$NON-NLS-1$ node.setAttribute("toQuantity", String.valueOf(split.getToQuantity())); //$NON-NLS-1$ element.appendChild(node); } for (Iterator iter = security.getDividends().iterator(); iter.hasNext();) { Dividend dividend = (Dividend) iter.next(); node = document.createElement("dividend"); //$NON-NLS-1$ node.setAttribute("date", dateTimeFormat.format(dividend.getDate())); //$NON-NLS-1$ node.setAttribute("value", String.valueOf(dividend.getValue())); //$NON-NLS-1$ element.appendChild(node); } }
From source file:com.shahnami.fetch.Controller.FetchMovies.java
public List<Movie> getBollyMovies(String query) { try {/* w w w. j a v a2 s .c o m*/ Document doc; Elements searchDetails; String link; String title; String image = null; Elements linkAndTitles; Document movieDetails; double rating = 0; String magnetLink; String torrentFile; NumberFormat formatter; String output; if (query.equalsIgnoreCase("")) { // } else { doc = Jsoup.connect("https://1337x.to/search/" + URLEncoder.encode(query, "UTF-8") + "+hindi/1/") .userAgent("Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.2) Gecko/20040803").get(); searchDetails = doc.getElementsByClass("coll-1"); for (Element e : searchDetails) { linkAndTitles = e.getElementsByTag("strong"); for (Element e1 : linkAndTitles) { link = "https://1337x.to" + e1.getElementsByTag("a").first().attr("href"); title = e1.getElementsByTag("a").first().html(); if (!link.contains("/mirror")) { Movie m = new Movie(); m.setTitle(title.replace("<b>", "").replace("</b>", "").trim()); //.substring(0, 47)+ "..." m.setLanguage("Hindi"); m.setUrl(link); Pattern pattern = Pattern.compile(".*([\\s(]+[0-9]{4}[\\s)]+).*"); Matcher matcher = pattern.matcher(title); while (matcher.find()) { m.setYear(Integer .parseInt(matcher.group(1).replace("(", "").replace(")", "").trim())); } movieDetails = Jsoup.connect(link).get(); try { image = movieDetails.getElementsByClass("moive-box").first().getElementsByTag("img") .first().attr("src"); rating = Float.parseFloat( movieDetails.getElementsByClass("rateing").first().getElementsByTag("i") .attr("style").split(":")[1].replace("%;", "").trim()); } catch (Exception ex) { // } magnetLink = movieDetails.getElementsByClass("magnet").first().attr("href"); torrentFile = movieDetails.getElementsByClass("torrent").first().attr("href"); formatter = NumberFormat.getNumberInstance(); formatter.setMinimumFractionDigits(2); formatter.setMaximumFractionDigits(2); output = formatter.format(rating / 10); rating = Double.parseDouble(output); if (rating < 1) { rating = 0; } m.setRating(rating); m.setSmall_cover_image(image); List<Torrent> torrents = new ArrayList<>(); Torrent t = new Torrent(); t.setUrl(magnetLink); Torrent t2 = new Torrent(); t2.setUrl(torrentFile); torrents.add(t); torrents.add(t2); m.setTorrents(torrents); m.getTorrents().get(0).setSeeds( Integer.valueOf(movieDetails.getElementsByClass("green").first().text())); m.getTorrents().get(0).setPeers( Integer.valueOf(movieDetails.getElementsByClass("red").first().text())); m.setIsBollywood(true); m.setSize(movieDetails.getElementsByClass("list").first().getElementsByTag("li").get(3) .text().substring(10).trim()); _movies.add(m); } } //String link = linkAndTitle.getElementsByAttribute("href").first().text(); //System.out.println(link); //String title = linkAndTitle.getElementsByTag("b").text(); //System.out.println(title); } } } catch (UnsupportedEncodingException ex) { Logger.getLogger(FetchMovies.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(FetchMovies.class.getName()).log(Level.SEVERE, null, ex); } return _movies; }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
public void buttonPDT_actionPerformed(ActionEvent event) { try {//from w ww . jav a 2 s . co m NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); String answer = nf.format(_precursorDiscoveryMzTolerance); String newAnswer = JOptionPane.showInputDialog("New value for precursor tolerance:", answer); _precursorDiscoveryMzTolerance = (float) Double.parseDouble(newAnswer); initStuff(); } catch (Exception e) { ApplicationContext.infoMessage("Bad value for precursor tolerance."); } }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
public void buttonDTOL_actionPerformed(ActionEvent event) { try {//w ww. j a v a 2 s . com NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(4); nf.setMinimumFractionDigits(4); String answer = nf.format(_daughterMzTolerance); String newAnswer = JOptionPane.showInputDialog("New value for product tolerance:", answer); _daughterMzTolerance = (float) Double.parseDouble(newAnswer); initStuff(); } catch (Exception e) { ApplicationContext.infoMessage("Bad value for product tolerance."); } }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
protected XYSeries makeParentSeries(MRMTransition parent) { float minMz = parent.getPrecursorMz() - _precursorDiscoveryMzTolerance - _precursorChromatogramWindow; float maxMz = parent.getPrecursorMz() + _precursorDiscoveryMzTolerance + _precursorChromatogramWindow; NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(1);// ww w. jav a 2 s . c om nf.setMinimumFractionDigits(1); XYSeries result = new XYSeries(parent.getName() + "\u00B1" + nf.format(_precursorDiscoveryMzTolerance + _precursorChromatogramWindow)); //precursor scans for (int i = parent.getMinScanOfDaughters(); i <= parent.getMaxScanOfDaughters(); i++) { int scanNum = _run.getIndexForScanNum(i); if (scanNum <= 0) continue; MSRun.MSScan ms1Scan = _run.getScan(scanNum); boolean sim_only = _sim; String scanType = ms1Scan.getScanType(); if (!sim_only || (sim_only && scanType.equalsIgnoreCase("SIM"))) result.add(ms1Scan.getDoubleRetentionTime(), Utils.getMaxIntensityForScan(ms1Scan, minMz, maxMz)); } return result; }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
public void buttonSICUpdate_actionPerformed(ActionEvent event) { try {//from w w w. j av a 2s .c o m NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); String answer = nf.format(_precursorChromatogramWindow); String newAnswer = JOptionPane.showInputDialog("New value for MS1 SIC tolerance:", answer); _precursorChromatogramWindow = (float) Double.parseDouble(newAnswer); for (MRMTransition t : _mrmTransitions) { t.setGraphData(null); for (MRMDaughter d : t.getDaughters().values()) { d.setGraphData(null); } } updateChartsAndFields(false); } catch (Exception e) { ApplicationContext.infoMessage("Bad value for MZ tolerance, please try again"); } }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
public void menuItemAMin_actionPerformed(ActionEvent event) { try {/*from ww w. j av a2 s . com*/ NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); nf.setGroupingUsed(false); String answer = nf.format(_minAreaCutoff); String newAnswer = JOptionPane.showInputDialog("New value for min AUC cutoff:", answer); if (newAnswer == null) return; float newCutoff = Float.parseFloat(newAnswer); if (newCutoff > 0.0f) { for (MRMTransition mrt : _mrmTransitions) { for (MRMDaughter curd : mrt.getDaughters().values()) { if (curd.getBestElutionCurve() != null && curd.getBestElutionCurve().getAUC() < newCutoff) { ((PeaksTableModel) (peaksTable.getModel())).setValueAt(new Boolean(false), curd.getElutionDataTableRow(), peaksData.Accept.colno); } } } } _minAreaCutoff = newCutoff; } catch (Exception e) { ApplicationContext.infoMessage("Failed to change min acceptable AUC: " + e); } }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
public void menuItemPMin_actionPerformed(ActionEvent event) { try {//from ww w .j a va2s . c o m NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); nf.setGroupingUsed(false); String answer = nf.format(_minPeakCutoff); String newAnswer = JOptionPane.showInputDialog("New value for min peak cutoff:", answer); if (newAnswer == null) return; float newCutoff = Float.parseFloat(newAnswer); if (newCutoff > 0.0f) { for (MRMTransition mrt : _mrmTransitions) { for (MRMDaughter curd : mrt.getDaughters().values()) { if (curd.getBestElutionCurve() != null && curd.getBestElutionCurve().getHighestPointY() < newCutoff) { ((PeaksTableModel) (peaksTable.getModel())).setValueAt(new Boolean(false), curd.getElutionDataTableRow(), peaksData.Accept.colno); } } } } _minPeakCutoff = newCutoff; } catch (Exception e) { ApplicationContext.infoMessage("Failed to change min acceptable peak height: " + e); } }
From source file:org.kuali.kfs.gl.batch.service.impl.ScrubberProcessImpl.java
/** * Generate the flag for the end of specific descriptions. This will be used in the demerger step *///from www . java 2 s . co m protected void setOffsetString() { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(0); nf.setMaximumIntegerDigits(2); nf.setMinimumFractionDigits(0); nf.setMinimumIntegerDigits(2); offsetString = COST_SHARE_TRANSFER_ENTRY_IND + nf.format(runCal.get(Calendar.MONTH) + 1) + nf.format(runCal.get(Calendar.DAY_OF_MONTH)); }
From source file:com.att.pirates.controller.ProjectController.java
private static void getAppProjectArtifactHistory() { // TODO: port over to hibernate later artifactHistory = new ArrayList<AppProjectArtifactOwnersHistory>(); // logger.error(msgHeader + "getAppProjectArtifactHistory called. "); ResultSet rs = null;/*from w w w . j av a 2 s.co m*/ Connection conn = null; PreparedStatement preparedStatement = null; try { conn = DBUtility.getDBConnection(); // SQL query command String SQL = " Select UUID " + " ,DueDate " + " ,CompletionDate " + " ,PercentageComplete " + " ,ArtifactName " + " ,PRISMId " + " ,ApplicationName " + " ,ModuleId " + " ,IsPrimaryOwner " + " ,MileStoneId " + " ,ExecutionPercentage " + " ,ProjectCloseOutPercentage " + " ,DateLogged " + " ,DateCreated " + " ,SystemNote " + " ,UpdatedByUUID " + " from dbo.AppProjectArtifactOwnersHistory " + " order by PRISMId, ApplicationName, ArtifactName, DateLogged desc "; preparedStatement = conn.prepareStatement(SQL); rs = preparedStatement.executeQuery(); int rowCount = 0; while (rs.next()) { rowCount++; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat yFormat = new SimpleDateFormat("MM/dd/yyyy"); // for percentage NumberFormat defaultFormat = NumberFormat.getPercentInstance(); defaultFormat.setMinimumFractionDigits(0); // String uuid = rs.getString("UUID"); // String theDueDate = rs.getString("DueDate"); String dueDate = yFormat.format(format.parse(theDueDate)); // String theCompDate = rs.getString("CompletionDate") == null ? "1900-01-01 14:58:00.00" : rs.getString("CompletionDate"); String completionDate = yFormat.format(format.parse(theCompDate)); // double percentComplete = Double.parseDouble( rs.getString("PercentageComplete") == null ? "0" : rs.getString("PercentageComplete")); String PercentCompleted = defaultFormat.format(percentComplete); // String artifactName = rs.getString("ArtifactName"); // String applicationName = rs.getString("ApplicationName"); // String moduleId = rs.getString("ModuleId"); // String isPrimary = rs.getString("IsPrimaryOwner"); // String mileStoneId = rs.getString("MileStoneId"); // double ExecPercent = Double.parseDouble( rs.getString("ExecutionPercentage") == null ? "0" : rs.getString("ExecutionPercentage")); String ExecutionPercentage = defaultFormat.format(ExecPercent); // double prjCOPercent = Double.parseDouble(rs.getString("ProjectCloseOutPercentage") == null ? "0" : rs.getString("ProjectCloseOutPercentage")); String PrjCloseOutPercentage = defaultFormat.format(prjCOPercent); // String logCreated = rs.getString("DateLogged"); String dateLogged = yFormat.format(format.parse(logCreated)); // String dCreated = rs.getString("DateCreated") == null ? rs.getString("DateLogged") : rs.getString("DateCreated"); String dateCreated = yFormat.format(format.parse(dCreated)); // String updatedByUUID = rs.getString("UpdatedByUUID"); // String systemNote = rs.getString("SystemNote"); // String prismID = rs.getString("PRISMId"); AppProjectArtifactOwnersHistory p = new AppProjectArtifactOwnersHistory(); p.setUUID(uuid); p.setDueDate(dueDate); p.setCompletionDate(completionDate); p.setPercentageComplete(PercentCompleted); p.setArtifactName(artifactName); p.setPRISMId(prismID); // PRISMId p.setApplicationName(applicationName); p.setModuleId(moduleId); p.setIsPrimaryOwner(isPrimary.equalsIgnoreCase("1")); p.setMileStoneId(mileStoneId); p.setExecutionPercentage(ExecutionPercentage); p.setProjectCloseOutPercentage(PrjCloseOutPercentage); p.setDateCreated(dateCreated); p.setUpdatedByUUID(updatedByUUID); p.setSystemNote(systemNote); p.setDateLogged(dateLogged); artifactHistory.add(p); } // logger.error(msgHeader + "getStatusHistoryListByApplicationOwner called, got results: "+rowCount); } catch (SQLException e) { logger.error(e.getMessage()); } catch (Exception e) { logger.error(e.getMessage()); } finally { try { if (rs != null) rs.close(); } catch (Exception e) { } ; try { if (preparedStatement != null) preparedStatement.close(); } catch (Exception e) { } ; try { if (conn != null) conn.close(); } catch (Exception e) { } ; } }