List of usage examples for java.text DecimalFormat format
public final String format(double number)
From source file:Interface.ResultadoJanela.java
public Object[][] criarValores(List<Resultado> tar, List<Resultado> jac, List<Resultado> och, List<Resultado> sbi) { Object[][] valores = new Object[tar.size()][6]; DecimalFormat df = new DecimalFormat("#.00"); for (int i = 0; i < tar.size(); i++) { valores[i][0] = tar.get(i).getLinha(); // primeira coluna "Linha" valores[i][1] = tar.get(i).getClasse(); valores[i][2] = df.format((tar.get(i).getProbabilidade() * 100)); valores[i][3] = df.format(jac.get(i).getProbabilidade() * 100); valores[i][4] = df.format(och.get(i).getProbabilidade() * 100); valores[i][5] = df.format(sbi.get(i).getProbabilidade() * 100); }/* ww w . j av a 2s . c o m*/ return valores; }
From source file:com.archsystemsinc.ipms.sec.webapp.controller.ReportsController.java
@RequestMapping(value = "/statusreport", method = RequestMethod.POST) public String statusReportPost(final Model model, final Principal principal, HttpServletRequest request) { Long id = Long.parseLong(request.getParameter("projectId")); Project project = projectService.findOne(id); request.setAttribute("projectId", id); model.addAttribute("projects", projectService.findAll()); final List<Issue> issues = new ArrayList<Issue>(); issues.addAll(project.getIssues());//from www.j a v a 2 s . c om int openProgressIssues = 0; for (Issue issue : issues) { if (StringUtils.equalsIgnoreCase(issue.getStatus(), IssueStatus.Open.toString()) || StringUtils.equalsIgnoreCase(issue.getStatus(), IssueStatus.In_Progress.toString())) { openProgressIssues++; } } double issueResolutionRate = 0; if (issues != null && issues.size() > 0) issueResolutionRate = openProgressIssues / issues.size(); DecimalFormat formatter = new DecimalFormat("0.00"); formatter.format(issueResolutionRate); model.addAttribute("issues", project.getIssues()); model.addAttribute("issueResolutionRate", issueResolutionRate); final List<ActionItem> actionItems = new ArrayList<ActionItem>(); actionItems.addAll(project.getActionItems()); Collections.sort(actionItems); int openProgressActionItems = 0; for (ActionItem actionItem : actionItems) { if (StringUtils.equalsIgnoreCase(actionItem.getStatus(), IssueStatus.Open.toString()) || StringUtils.equalsIgnoreCase(actionItem.getStatus(), IssueStatus.In_Progress.toString())) { openProgressActionItems++; } } double actionItemResolutionRate = 0; if (actionItems != null && actionItems.size() > 0) actionItemResolutionRate = openProgressActionItems / actionItems.size(); formatter.format(issueResolutionRate); model.addAttribute("issues", project.getIssues()); model.addAttribute("actionItems", project.getActionItems()); model.addAttribute("actionItemResolutionRate", actionItemResolutionRate); model.addAttribute("lessonsLearned", project.getLessonsLearned()); model.addAttribute("risks", project.getRisks()); final List<Meeting> meetings = meetingService.findAll(); model.addAttribute("meetings", meetings); return "statusreport"; }
From source file:com.alibaba.jstorm.utils.JStormUtils.java
public static String formatSimpleDouble(Double value) { try {/*w w w.j a v a 2 s .c o m*/ java.text.DecimalFormat form = new java.text.DecimalFormat("##0.000"); String s = form.format(value); return s; } catch (Exception e) { return "0.000"; } }
From source file:com.alibaba.jstorm.utils.JStormUtils.java
public static double formatDoubleDecPoint4(Double value) { try {/*from w w w .j a va 2s. c om*/ java.text.DecimalFormat form = new java.text.DecimalFormat("###.0000"); String s = form.format(value); return Double.valueOf(s); } catch (Exception e) { return 0.0; } }
From source file:com.bigml.histogram.Bin.java
/** * Append a text representation of this bin to the specified appendable. * * @param appendable appendable to append to, must not be null * @param format decimal format, must not be null * @throws IOException if an error occurs *//*from w ww . ja v a2 s. c om*/ public void appendTo(final Appendable appendable, final DecimalFormat format) throws IOException { if (appendable == null) { throw new NullPointerException("appendable must not be null"); } if (format == null) { throw new NullPointerException("format must not be null"); } appendable.append(format.format(_mean)); appendable.append("\t"); appendable.append(format.format(_count)); appendable.append("\t"); _target.appendTo(appendable, format); appendable.append("\n"); }
From source file:edu.nwpu.gemfire.monitor.service.ClusterRegionsService.java
/** * This method is used to get various regions associated with the given * cluster and create json for each region fields and returns Array List for * all the regions associated with given cluster * /*from w w w . j a v a 2 s . c o m*/ * @param cluster * @return JSONObject Array List */ private ArrayNode getRegionJson(Cluster cluster) { Long totalHeapSize = cluster.getTotalHeapSize(); Long totalDiskUsage = cluster.getTotalBytesOnDisk(); Map<String, Cluster.Region> clusterRegions = cluster.getClusterRegions(); List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>(); clusterRegionsList.addAll(clusterRegions.values()); Collections.sort(clusterRegionsList, regionEntryCountComparator); ArrayNode regionListJson = mapper.createArrayNode(); for (int count = 0; count < clusterRegionsList.size(); count++) { Cluster.Region reg = clusterRegionsList.get(count); ObjectNode regionJSON = mapper.createObjectNode(); regionJSON.put("name", reg.getName()); regionJSON.put("totalMemory", totalHeapSize); regionJSON.put("systemRegionEntryCount", reg.getSystemRegionEntryCount()); regionJSON.put("memberCount", reg.getMemberCount()); final String regionType = reg.getRegionType(); regionJSON.put("type", regionType); regionJSON.put("getsRate", reg.getGetsRate()); regionJSON.put("putsRate", reg.getPutsRate()); Cluster.Member[] clusterMembersList = cluster.getMembers(); ArrayNode memberNameArray = mapper.createArrayNode(); for (String memberName : reg.getMemberName()) { for (Cluster.Member member : clusterMembersList) { String name = member.getName(); name = name.replace(":", "-"); String id = member.getId(); id = id.replace(":", "-"); if ((memberName.equals(id)) || (memberName.equals(name))) { ObjectNode regionMember = mapper.createObjectNode(); regionMember.put("id", member.getId()); regionMember.put("name", member.getName()); memberNameArray.add(regionMember); break; } } } regionJSON.put("memberNames", memberNameArray); regionJSON.put("entryCount", reg.getSystemRegionEntryCount()); Boolean persistent = reg.getPersistentEnabled(); if (persistent) { regionJSON.put("persistence", this.VALUE_ON); } else { regionJSON.put("persistence", this.VALUE_OFF); } Boolean isEnableOffHeapMemory = reg.isEnableOffHeapMemory(); if (isEnableOffHeapMemory) { regionJSON.put("isEnableOffHeapMemory", this.VALUE_ON); } else { regionJSON.put("isEnableOffHeapMemory", this.VALUE_OFF); } Boolean isHDFSWriteOnly = reg.isHdfsWriteOnly(); if (regionType.startsWith("HDFS")) { if (isHDFSWriteOnly) { regionJSON.put("isHDFSWriteOnly", this.VALUE_ON); } else { regionJSON.put("isHDFSWriteOnly", this.VALUE_OFF); } } else { regionJSON.put("isHDFSWriteOnly", this.VALUE_NA); } String regCompCodec = reg.getCompressionCodec(); if (StringUtils.isNotNullNotEmptyNotWhiteSpace(regCompCodec)) { regionJSON.put("compressionCodec", reg.getCompressionCodec()); } else { regionJSON.put("compressionCodec", this.VALUE_NA); } if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController.getPulseProductSupport())) { // Convert region path to dot separated region path regionJSON.put("regionPath", StringUtils.getTableNameFromRegionName(reg.getFullPath())); regionJSON.put("id", StringUtils.getTableNameFromRegionName(reg.getFullPath())); } else { regionJSON.put("regionPath", reg.getFullPath()); regionJSON.put("id", reg.getFullPath()); } regionJSON.put("memoryReadsTrend", mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_GETS_PER_SEC_TREND))); regionJSON.put("memoryWritesTrend", mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_PUTS_PER_SEC_TREND))); regionJSON.put("diskReadsTrend", mapper .valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_READS_PER_SEC_TREND))); regionJSON.put("diskWritesTrend", mapper.valueToTree( reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_WRITES_PER_SEC_TREND))); regionJSON.put("emptyNodes", reg.getEmptyNode()); Long entrySize = reg.getEntrySize(); DecimalFormat form = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN_2); String entrySizeInMB = form.format(entrySize / (1024f * 1024f)); if (entrySize < 0) { regionJSON.put(this.ENTRY_SIZE, this.VALUE_NA); } else { regionJSON.put(this.ENTRY_SIZE, entrySizeInMB); } regionJSON.put("dataUsage", reg.getDiskUsage()); regionJSON.put("wanEnabled", reg.getWanEnabled()); regionJSON.put("totalDataUsage", totalDiskUsage); regionJSON.put("memoryUsage", entrySizeInMB); regionListJson.add(regionJSON); } return regionListJson; }
From source file:edu.nwpu.gemfire.monitor.service.ClusterRegionService.java
/** * This method is used to get various regions associated with the given * cluster and create json for each region fields and returns Array List for * all the regions associated with given cluster * * @param cluster/*w ww. j a va 2 s . c om*/ * @return ArrayNode Array List */ private ArrayNode getRegionJson(Cluster cluster) { Long totalHeapSize = cluster.getTotalHeapSize(); Long totalDiskUsage = cluster.getTotalBytesOnDisk(); Map<String, Cluster.Region> clusterRegions = cluster.getClusterRegions(); List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>(); clusterRegionsList.addAll(clusterRegions.values()); Collections.sort(clusterRegionsList, regionEntryCountComparator); ArrayNode regionListJson = mapper.createArrayNode(); for (int count = 0; count < clusterRegionsList.size(); count++) { Cluster.Region reg = clusterRegionsList.get(count); ObjectNode regionJSON = mapper.createObjectNode(); regionJSON.put("name", reg.getName()); regionJSON.put("totalMemory", totalHeapSize); regionJSON.put("systemRegionEntryCount", reg.getSystemRegionEntryCount()); regionJSON.put("memberCount", reg.getMemberCount()); final String regionType = reg.getRegionType(); regionJSON.put("type", regionType); regionJSON.put("getsRate", reg.getGetsRate()); regionJSON.put("putsRate", reg.getPutsRate()); Cluster.Member[] clusterMembersList = cluster.getMembers(); ArrayNode memberNameArray = mapper.createArrayNode(); for (String memberName : reg.getMemberName()) { for (Cluster.Member member : clusterMembersList) { String name = member.getName(); name = name.replace(":", "-"); String id = member.getId(); id = id.replace(":", "-"); if ((memberName.equals(id)) || (memberName.equals(name))) { ObjectNode regionMember = mapper.createObjectNode(); regionMember.put("id", member.getId()); regionMember.put("name", member.getName()); memberNameArray.add(regionMember); break; } } } regionJSON.put("memberNames", memberNameArray); regionJSON.put("entryCount", reg.getSystemRegionEntryCount()); Boolean persistent = reg.getPersistentEnabled(); if (persistent) { regionJSON.put("persistence", VALUE_ON); } else { regionJSON.put("persistence", VALUE_OFF); } Boolean isEnableOffHeapMemory = reg.isEnableOffHeapMemory(); if (isEnableOffHeapMemory) { regionJSON.put("isEnableOffHeapMemory", VALUE_ON); } else { regionJSON.put("isEnableOffHeapMemory", VALUE_OFF); } Boolean isHDFSWriteOnly = reg.isHdfsWriteOnly(); if (regionType.startsWith("HDFS")) { if (isHDFSWriteOnly) { regionJSON.put("isHDFSWriteOnly", VALUE_ON); } else { regionJSON.put("isHDFSWriteOnly", VALUE_OFF); } } else { regionJSON.put("isHDFSWriteOnly", VALUE_NA); } String regCompCodec = reg.getCompressionCodec(); if (StringUtils.isNotNullNotEmptyNotWhiteSpace(regCompCodec)) { regionJSON.put("compressionCodec", reg.getCompressionCodec()); } else { regionJSON.put("compressionCodec", VALUE_NA); } if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController.getPulseProductSupport())) { // Convert region path to dot separated region path regionJSON.put("regionPath", StringUtils.getTableNameFromRegionName(reg.getFullPath())); } else { regionJSON.put("regionPath", reg.getFullPath()); } regionJSON.put("memoryReadsTrend", mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_GETS_PER_SEC_TREND))); regionJSON.put("memoryWritesTrend", mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_PUTS_PER_SEC_TREND))); regionJSON.put("diskReadsTrend", mapper .valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_READS_PER_SEC_TREND))); regionJSON.put("diskWritesTrend", mapper.valueToTree( reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_WRITES_PER_SEC_TREND))); regionJSON.put("emptyNodes", reg.getEmptyNode()); Long entrySize = reg.getEntrySize(); DecimalFormat form = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN_2); String entrySizeInMB = form.format(entrySize / (1024f * 1024f)); if (entrySize < 0) { regionJSON.put(this.ENTRY_SIZE, VALUE_NA); } else { regionJSON.put(this.ENTRY_SIZE, entrySizeInMB); } regionJSON.put("dataUsage", reg.getDiskUsage()); regionJSON.put("wanEnabled", reg.getWanEnabled()); regionJSON.put("totalDataUsage", totalDiskUsage); regionJSON.put("memoryUsage", entrySizeInMB); regionListJson.add(regionJSON); } return regionListJson; }
From source file:com.joliciel.csvLearner.features.RealValueFeatureEvaluator.java
public void logPerformance() { DecimalFormat df = new DecimalFormat("0.00"); LOG.info("total time: " + totalTime + " milliseconds"); LOG.info("total initialise time: " + totalTimeInitialise + " milliseconds. " + df.format(((double) totalTimeInitialise / (double) totalTime) * 100.0) + "%"); LOG.info("total find feature time: " + totalTimeFindFeature + " milliseconds. " + df.format(((double) totalTimeFindFeature / (double) totalTime) * 100.0) + "%"); LOG.info("total sort time: " + totalTimeOrdering + " milliseconds. " + df.format(((double) totalTimeOrdering / (double) totalTime) * 100.0) + "%"); LOG.info("total split time: " + totalTimeSplit + " milliseconds. " + df.format(((double) totalTimeSplit / (double) totalTime) * 100.0) + "%"); LOG.info("total initial entropy time: " + totalTimeInitialEntropy + " milliseconds. " + df.format(((double) totalTimeInitialEntropy / (double) totalTime) * 100.0) + "%"); LOG.info("total split entropy time: " + totalTimeSplitEntropy + " milliseconds. " + df.format(((double) totalTimeSplitEntropy / (double) totalTime) * 100.0) + "%"); }
From source file:com.wuliu.biz.orderbusiness.service.impl.WuliuMergedOrderServiceImpl.java
@Override public PageResultModel<WuliuMergedOrderModel> queryMergedOrders(WuliuOrderQueryParam wuliuOrderQueryParam) { PageResultModel<WuliuMergedOrderModel> ret = new PageResultModel<WuliuMergedOrderModel>(); if (wuliuOrderQueryParam == null) { return ret; }/* www . j av a 2 s .c o m*/ List<WuliuOrderModel> wuliuOrderModels = wuliuOrderAO.queryOrders(wuliuOrderQueryParam); if (CollectionUtils.isEmpty(wuliuOrderModels)) { return ret; } Map<Long, WuliuMemberModel> wuliuMemberMap = new HashMap<Long, WuliuMemberModel>(); for (WuliuOrderModel item : wuliuOrderModels) { if (wuliuMemberMap.containsKey(item.getMemberId())) { continue; } WuliuMemberModel wuliuMemberModel = wuliuMemberAO.queryMemberWithId(item.getMemberId()); wuliuMemberMap.put(item.getMemberId(), wuliuMemberModel); } List<WuliuMergedOrderModel> wuliuMergedOrderModels = new ArrayList<WuliuMergedOrderModel>(); for (WuliuOrderModel item : wuliuOrderModels) { WuliuOrderDetailQueryParam wuliuOrderDetailQueryParam = new WuliuOrderDetailQueryParam(); wuliuOrderDetailQueryParam.setMainOrderId(item.getId()); WuliuMergedOrderModel wuliuMergedOrderModel = new WuliuMergedOrderModel(); wuliuMergedOrderModel.setCarIndex(item.getCarIndex()); wuliuMergedOrderModel.setDaishouFee(item.getDaishouFee()); wuliuMergedOrderModel.setId(item.getId()); wuliuMergedOrderModel.setJiashouFee(item.getJiashouFee()); wuliuMergedOrderModel.setMemberId(item.getMemberId()); wuliuMergedOrderModel.setOrderDate(item.getOrderDate()); wuliuMergedOrderModel.setOrderNumber(item.getOrderNumber()); wuliuMergedOrderModel.setZhongzhuanFee(item.getZhongzhuanFee()); DecimalFormat df = new DecimalFormat("0.##"); if (wuliuMergedOrderModel.getJiashouFee() != null) { wuliuMergedOrderModel .setJiashouFeeForDisplay(df.format(wuliuMergedOrderModel.getJiashouFee() / 100.0)); } if (wuliuMergedOrderModel.getDaishouFee() != null) { wuliuMergedOrderModel .setDaishouFeeForDisplay(df.format(wuliuMergedOrderModel.getDaishouFee() / 100.0)); } if (wuliuMergedOrderModel.getZhongzhuanFee() != null) { wuliuMergedOrderModel .setZhongzhuanFeeForDisplay(df.format(wuliuMergedOrderModel.getZhongzhuanFee() / 100.0)); ; } List<WuliuOrderDetailModel> wuliuOrderDetailModels = wuliuOrderDetailAO .queryOrderDetails(wuliuOrderDetailQueryParam); int count = 0; for (WuliuOrderDetailModel detailItem : wuliuOrderDetailModels) { count += detailItem.getCount(); } WuliuMemberModel wuliuMemberModel = wuliuMemberMap.get(item.getMemberId()); if (wuliuMemberModel == null) { continue; } wuliuMergedOrderModel.setName(wuliuMemberModel.getName()); wuliuMergedOrderModel.setAddress(wuliuMemberModel.getAddress()); wuliuMergedOrderModel.setTelephoneNumber(wuliuMemberModel.getTelephoneNumber()); wuliuMergedOrderModel.setMobileNumber(wuliuMemberModel.getMobileNumber()); wuliuMergedOrderModel.setOrderNumber(item.getOrderNumber()); wuliuMergedOrderModel.setSendDate(CalendarUtil.addDays(item.getOrderDate(), SEND_DAYS)); wuliuMergedOrderModel.setWuliuMergedOrderDetailModels(orderDetailMergeEngine.mergeOrderDetail( wuliuOrderDetailModels, wuliuMemberModel.getWeightPrice(), wuliuMemberModel.getVolumnPrice())); wuliuMergedOrderModels.add(wuliuMergedOrderModel); } ret.setPageNum(wuliuOrderQueryParam.getPageNum()); ret.setPageSize(wuliuOrderQueryParam.getPageSize()); ret.setResultList(wuliuMergedOrderModels); ret.setTotalCount(wuliuOrderAO.countOrders(wuliuOrderQueryParam)); return ret; }