Examples of NumberFormat


Examples of java.text.NumberFormat

    public static void main(String[] args) {
      // set decimal display to ","
      //Locale.setDefault(Locale.GERMAN);
     
      double d = 0.000003991630774821635;
      NumberFormat nf =  NumberFormat.getNumberInstance();
      nf.setMaximumFractionDigits(6);
      nf.setMinimumFractionDigits(6);
      String s = nf.format(d);
     
      System.out.println("Actual: " + d)// Displays 3.991630774821635E-6
      System.out.println("NF/6:   " + s)// Displays 0.000004
      // should display 0.000003
      System.out.println("DF:     " + DisplayFormatters.formatDecimal(d , 6));
View Full Code Here

Examples of java.text.NumberFormat

            doubleResult = round(value / TB);
            suffix = "Tb";
        }

        try {
            NumberFormat nf = NumberFormat.getInstance();
            nf.setMinimumFractionDigits(fractions);
            String title = Long.toString((long) value);
            String newValue = nf.format(doubleResult) + suffix;
            pageContext.getOut().write("<span title=\"" + title + "\">" + newValue + "</span>");
        } catch (IOException e) {
            logger.debug(e);
            throw new JspException(e);
        }
View Full Code Here

Examples of java.text.NumberFormat

      opportunityVO.setStatusID(Integer.parseInt(opportunityForm.getStatusid()));
      opportunityVO.setStageID(Integer.parseInt(opportunityForm.getStageid()));
      String Totalamount = opportunityForm.getTotalamount();
      if (Totalamount != null) {
        Totalamount = Totalamount.replaceAll(" ", "");//remove empty spaces
        NumberFormat nf = NumberFormat.getInstance();       
        Totalamount = nf.parse(Totalamount).toString();
      }
      opportunityVO.setActualAmount(Float.parseFloat(Totalamount));
      opportunityVO.setProbability(Integer.parseInt(opportunityForm.getProbabilityid()));
      opportunityVO.setForecastedAmount(Float.parseFloat(Totalamount));
      opportunityVO.setSourceID(Integer.parseInt(opportunityForm.getSourceid()));
View Full Code Here

Examples of java.text.NumberFormat

      pieData.setValue(stageName + " (" + count.toString() + ")", forecastAmount);
    }

    // format the totals as US Currency
    NumberFormat numFormatter = NumberFormat.getCurrencyInstance();
    String totalForecastString = numFormatter.format(totalForecast);
    String totalActualString = numFormatter.format(totalActual);

    // create the chart
    JFreeChart pieChart = ChartFactory.createPieChart("Opportunities by Stage", pieData, true, true, false);

    // set the sub-title
View Full Code Here

Examples of java.text.NumberFormat

      if (!opportunityForm.getTotalamount().trim().equals("")) {
        String Totalamount = opportunityForm.getTotalamount();
        if (Totalamount != null) {
          Totalamount = Totalamount.replaceAll(" ", "");// remove empty spaces
          NumberFormat nf = NumberFormat.getInstance();
          Totalamount = nf.parse(Totalamount).toString();
        }
        opportunityVO.setActualAmount(Float.parseFloat(Totalamount));
      }

      String ForecastedAmount = opportunityForm.getForecastedamount();
      if (ForecastedAmount != null) {
        ForecastedAmount = ForecastedAmount.replaceAll(" ", "");// remove empty
                                                                // spaces
        NumberFormat nf = NumberFormat.getInstance();
        ForecastedAmount = nf.parse(ForecastedAmount).toString();
      }
      opportunityVO.setForecastedAmount(Float.parseFloat(ForecastedAmount));
      opportunityVO.setProbability(Integer.parseInt(opportunityForm.getProbabilityid()));

      if ((opportunityForm.getSourceid() != null)
View Full Code Here

Examples of java.text.NumberFormat

      totalActual += actualAmount.floatValue();

      chartData.setValue(forecastAmount, stageName, month);
    }

    NumberFormat numFormatter = NumberFormat.getCurrencyInstance();
    String totalForecastString = numFormatter.format(totalForecast);
    String totalActualString = numFormatter.format(totalActual);

    // create the chart
    JFreeChart barChart = ChartFactory.createStackedBarChart("Opportunities by Month", "Month", "Opportunity Value ($)",
                                                             chartData, org.jfree.chart.plot.PlotOrientation.VERTICAL,
                                                             true, true, false);
View Full Code Here

Examples of java.text.NumberFormat

        }
        else
        {
          mTemplate.setBlock("authenticated_content", "busy_content");
          mTemplate.setValue("percentage", percentage);
          NumberFormat format = NumberFormat.getInstance();
          format.setMinimumIntegerDigits(2);
          long eta_ms = sIndexingThread.getEta();
          if (eta_ms >= 0)
          {
            long eta_min = eta_ms/60000;
            long eta_s = (eta_ms-(eta_min*60000))/1000;
            mTemplate.setValue("eta_min", eta_min);
            mTemplate.setValue("eta_s", format.format(eta_s));
            mTemplate.setBlock("eta", "eta");
          }
          mTemplate.setValue("processedCount", sIndexingThread.getProcessedCount());
          mTemplate.setValue("totalCount", sIndexingThread.getTotalCount());
        }
View Full Code Here

Examples of java.text.NumberFormat

    return zoomModel;
  }

  protected final String formatZoomText(final double zoom)
  {
    final NumberFormat numberFormat =
        NumberFormat.getPercentInstance(swingGuiContext.getLocale());
    return (numberFormat.format(zoom));
  }
View Full Code Here

Examples of java.text.NumberFormat

  {
    styleBuilder.clear(); // cuts down on object creation

    final long nodeWidth = rc.getWidth();
    final long nodeHeight = rc.getHeight();
    final NumberFormat pointConverter = styleBuilder.getPointConverter();
    styleBuilder.append("overflow", "hidden"); //NON-NLS
    styleBuilder.append(WIDTH_STYLE, pointConverter.format//NON-NLS
        (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeWidth), safariLengthFix)), PT_UNIT);
    styleBuilder.append(HEIGHT_STYLE, pointConverter.format//NON-NLS
        (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeHeight), safariLengthFix)), PT_UNIT);
    return styleBuilder;
  }
View Full Code Here

Examples of java.text.NumberFormat

   */
  private StyleBuilder produceImageStyle(final RenderableReplacedContentBox rc)
  {
    styleBuilder.clear(); // cuts down on object creation

    final NumberFormat pointConverter = styleBuilder.getPointConverter();
    final RenderableReplacedContent content = rc.getContent();
    final long contentWidth = content.getContentWidth();
    final long nodeWidth = rc.getWidth();
    final long contentHeight = content.getContentHeight();
    final long nodeHeight = rc.getHeight();

    final StyleSheet styleSheet = rc.getStyleSheet();
    if (styleSheet.getBooleanStyleProperty(ElementStyleKeys.SCALE))
    {
      if (styleSheet.getBooleanStyleProperty(ElementStyleKeys.KEEP_ASPECT_RATIO) &&
          (contentWidth > 0 && contentHeight > 0))
      {
        final double scaleFactor = Math.min(nodeWidth / (double) contentWidth, nodeHeight / (double) contentHeight);

        styleBuilder.append(WIDTH_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue((long) (contentWidth * scaleFactor)),
                safariLengthFix)), PT_UNIT);
        styleBuilder.append(HEIGHT_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue((long) (contentHeight * scaleFactor)),
                safariLengthFix)), PT_UNIT);
      }
      else
      {
        styleBuilder.append(WIDTH_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeWidth), safariLengthFix)), PT_UNIT);
        styleBuilder.append(HEIGHT_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeHeight), safariLengthFix)), PT_UNIT);
      }
    }
    else
    {
      // for plain drawable content, there is no intrinsic-width or height, so we have to use the computed
      // width and height instead.
      if (contentWidth > nodeWidth || contentHeight > nodeHeight)
      {
        // There is clipping involved. The img-element does *not* receive a width or height property.
        // the width and height is applied to an external DIV element instead.
        return null;
      }

      if (contentWidth == 0 && contentHeight == 0)
      {
        // Drawable content has no intrinsic height or width, therefore we must not use the content size at all.
        styleBuilder.append(WIDTH_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeWidth), safariLengthFix)), PT_UNIT);
        styleBuilder.append(HEIGHT_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeHeight), safariLengthFix)), PT_UNIT);
      }
      else
      {
        final long width = Math.min(nodeWidth, contentWidth);
        final long height = Math.min(nodeHeight, contentHeight);
        styleBuilder.append(WIDTH_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(width), safariLengthFix)), PT_UNIT);
        styleBuilder.append(HEIGHT_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(height), safariLengthFix)), PT_UNIT);
      }
    }
    return styleBuilder;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.