Package java.text

Examples of java.text.NumberFormat.format()


                currencyFormat = DecimalFormat.getCurrencyInstance();
                currencyFormat.setCurrency(Currency.getInstance(currency));
              } else {
                currencyFormat = new DecimalFormat("##0.00");
              }
              value = currencyFormat.format(value);
            } else {
              value = "";
            }
            setHorizontalAlignment(JLabel.RIGHT);
            return super.getTableCellRendererComponent(
View Full Code Here


               int row, int column) {
            BigDecimal valueAddedTaxPercentage = ((CatalogPieceOfFurniture)value).getValueAddedTaxPercentage();
            if (valueAddedTaxPercentage != null) {
              NumberFormat percentInstance = DecimalFormat.getPercentInstance();
              percentInstance.setMinimumFractionDigits(valueAddedTaxPercentage.scale() - 2);
              value = percentInstance.format(valueAddedTaxPercentage);
            } else {
              value = "";
            }
            setHorizontalAlignment(JLabel.RIGHT);
            return super.getTableCellRendererComponent(
View Full Code Here

          content = "0";
        }
        valueString = content.toString();
        Double doubleValue = new Double(valueString);
        if (doubleValue != null) {
          String contentFormated = numFormatter.format(doubleValue.doubleValue());
          decoratedField.append(contentFormated);
        }
        break;
      case FieldDecoration.hourType:
        // We are using the old version of mysql we must have to do this..
View Full Code Here

  public String festival(){
    long[] ds = LunarCalendar.today();
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(0);
    nf.setMinimumIntegerDigits(2);
    String nongli = nf.format(ds[1]) + nf.format(ds[2]);
    Calendar cal = Calendar.getInstance();
    String yangli = nf.format(cal.get(Calendar.MONTH)+1)+nf.format(cal.get(Calendar.DATE));
    //System.out.printf("nongli=%s,yangli=%s\r\n",nongli,yangli);
    String f_nl = getMessage(request, "festival", 'Y'+nongli);
    String f_yl = getMessage(request, "festival", yangli);
View Full Code Here

  public String festival(){
    long[] ds = LunarCalendar.today();
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(0);
    nf.setMinimumIntegerDigits(2);
    String nongli = nf.format(ds[1]) + nf.format(ds[2]);
    Calendar cal = Calendar.getInstance();
    String yangli = nf.format(cal.get(Calendar.MONTH)+1)+nf.format(cal.get(Calendar.DATE));
    //System.out.printf("nongli=%s,yangli=%s\r\n",nongli,yangli);
    String f_nl = getMessage(request, "festival", 'Y'+nongli);
    String f_yl = getMessage(request, "festival", yangli);
View Full Code Here

    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(0);
    nf.setMinimumIntegerDigits(2);
    String nongli = nf.format(ds[1]) + nf.format(ds[2]);
    Calendar cal = Calendar.getInstance();
    String yangli = nf.format(cal.get(Calendar.MONTH)+1)+nf.format(cal.get(Calendar.DATE));
    //System.out.printf("nongli=%s,yangli=%s\r\n",nongli,yangli);
    String f_nl = getMessage(request, "festival", 'Y'+nongli);
    String f_yl = getMessage(request, "festival", yangli);
    if(f_nl!=null && f_yl!=null)
      return f_yl + "," + f_nl;
View Full Code Here

    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(0);
    nf.setMinimumIntegerDigits(2);
    String nongli = nf.format(ds[1]) + nf.format(ds[2]);
    Calendar cal = Calendar.getInstance();
    String yangli = nf.format(cal.get(Calendar.MONTH)+1)+nf.format(cal.get(Calendar.DATE));
    //System.out.printf("nongli=%s,yangli=%s\r\n",nongli,yangli);
    String f_nl = getMessage(request, "festival", 'Y'+nongli);
    String f_yl = getMessage(request, "festival", yangli);
    if(f_nl!=null && f_yl!=null)
      return f_yl + "," + f_nl;
View Full Code Here

      if (cache_index < cached_number_formats.length) {
        cached_number_formats[cache_index] = nf;
      }
    }

    return nf.format(tValue);
  }
 
      /**
       * Attempts vaguely smart string truncation by searching for largest token and truncating that
       * @param str
View Full Code Here

     
      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

        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

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.