Package java.text

Examples of java.text.DecimalFormat


  if (_formatSymbols != null) {
      // The name cannot be null - use empty string instead
      if (name == null) name = EMPTYSTRING;

      DecimalFormat df = (DecimalFormat)_formatSymbols.get(name);
      if (df == null) df = (DecimalFormat)_formatSymbols.get(EMPTYSTRING);
      return df;
  }
  return(null);
    }
View Full Code Here


        grpSep = ',';
        grpSize = 3;
    } else {
        DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(l);
        grpSep = dfs.getGroupingSeparator();
        DecimalFormat df = (DecimalFormat) NumberFormat.getIntegerInstance(l);
        grpSize = df.getGroupingSize();
    }
      }

      // localize the digits inserting group separators as necessary
      for (int j = 0; j < len; j++) {
View Full Code Here

                break;
            case 5: case 6:// integer
                newFormat = NumberFormat.getIntegerInstance(locale);
                break;
            default: // pattern
                newFormat = new DecimalFormat(segments[3].toString(), DecimalFormatSymbols.getInstance(locale));
                break;
            }
            break;
        case 3: case 4: // date
            switch (findKeyword(segments[3].toString(), dateModifierList)) {
View Full Code Here

  public static String getSize(int bytes) {
    if (bytes > 0) {
      double mb = bytes / (1024d * 1024d);
      double kb = bytes / 1024d;

      NumberFormat format = new DecimalFormat(Messages.OwlUI_SIZE_FORMAT);

      if (mb >= 1)
        return NLS.bind(Messages.OwlUI_N_MB, format.format(mb));

      if (kb >= 1)
        return NLS.bind(Messages.OwlUI_N_KB, format.format(kb));

      return NLS.bind(Messages.OwlUI_N_BYTES, bytes);
    }

    return null;
View Full Code Here

                return getLoaded(props);

            String num = "k";

            try {
                DecimalFormat nf = new DecimalFormat(
                        "###,###,###,##0.0;(#,##0.0)");

                double i = Double.parseDouble(props.getProperty("size"));
                i = i / 1024.0;

                num = nf.format(i) + num;
            } catch (NumberFormatException e) {
            }

            return num;
        }
View Full Code Here

  /**
   * @param n numbero of pages
   * @return
   */
    private DecimalFormat getFileNumberFormatter(Integer n){
      DecimalFormat retVal = null;
      if(n!=null){
        retVal = getFileNumberFormatter(n.intValue());
      }else{
        retVal = new DecimalFormat();
        retVal.applyPattern("00000");
      }
      return retVal;
    }
View Full Code Here

    /**
     * @param n number of pages
     * @return the DecimalFormat
     */
    private DecimalFormat getFileNumberFormatter(int n){
      DecimalFormat retVal = new DecimalFormat();
      try {
        retVal.applyPattern(Integer.toString(n).replaceAll("\\d", "0"));
    } catch (Exception fe) {
      retVal.applyPattern("00000");
    }
    return retVal;
    }
View Full Code Here

    /**
     * @param arg0 the input string of the type "####"
     * @return
     */
    private DecimalFormat getFileNumberFormatter(String arg0){
      DecimalFormat retVal = new DecimalFormat();
      try {
        if(arg0!=null && arg0.length()>0){
          retVal.applyPattern(arg0.replaceAll("#", "0"));
        }else{
          retVal.applyPattern("00000");
        }
    } catch (Exception fe) {
      retVal.applyPattern("00000");
    }
    return retVal;
    }
View Full Code Here

                Date end = new Date();
                long duration = end.getTime() - start.getTime();
                DateFormat df = new SimpleDateFormat( dFormat );
                BigDecimal resultF = BigDecimal.valueOf( (duration * 1.00) / (loops * 1.00) )
                        .setScale( 2, BigDecimal.ROUND_HALF_UP );
                DecimalFormat dcf = new DecimalFormat( "###.##" );

                msgs[0] = adapters[i].getClass().getName() + ';' + df.format( start ) + ';' + df.format( end ) + ';'
                        + duration + ";" + dcf.format( resultF );
                msgs[1] = "-1";

                if ( result == null || !(result instanceof ObjectBean)
                        || !((ObjectBean) result).getTheString().equals( "Accepted" ) )
                {
View Full Code Here

      int total = event.getWorkItemRep().getWorkItemCount(activityInstId);
      int finishCount = event.getWorkItemRep().getFinishedWorkItemCount(activityInstId);
     
      double c = Double.parseDouble(String.valueOf(finishCount)) / total;

      DecimalFormat df1 = new DecimalFormat("##.0000"); // ##.0000%  百分比格式,后面不足2位的用0补齐
      String d = df1.format(c);
     
      double finishPercent = Double.parseDouble(d)*100;
     
      double mustPercent = activityXml.getFinishRequiredPercent();
      if(finishPercent >= mustPercent)
View Full Code Here

TOP

Related Classes of java.text.DecimalFormat

Copyright © 2018 www.massapicom. 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.