Package java.text

Examples of java.text.DecimalFormat.format()


        return buf.toString();
    }

    public static String formatNumber(final long number) {
        DecimalFormat f = new DecimalFormat("#,###");
        return f.format(number);
    }

    public static String formatNumber(final double number) {
        return formatNumber(number, true);
    }
View Full Code Here


    }

    public static String formatNumber(final double number, boolean commaSep) {
        DecimalFormat f = new DecimalFormat(commaSep ? "#,###.###" : "###.###");
        f.setDecimalSeparatorAlwaysShown(false);
        return f.format(number);
    }
}
View Full Code Here

    {
      case 'a':
        return getShortStateString(dm.getState());
      case 'c':
        DecimalFormat df = new DecimalFormat("000.0%");
        return df.format(dm.getStats().getCompleted() / 1000.0);
      case 't':
        if (dm.getState() == DownloadManager.STATE_ERROR)
          return dm.getErrorDetails();
        else {
          if (dm.getDisplayName() == null)
View Full Code Here

            }
          }
        }
        DecimalFormat df1 = new DecimalFormat("000.0%");
        if (tot > 0) {
          return "      ("+df1.format(to * 1.0 / tot)+")";
        } else
          return "\t";
      case 'd':
        return DisplayFormatters.formatByteCountToKiBEtcPerSec(dm.getStats().getDataReceiveRate());
      case 'u':
View Full Code Here

        out.print(tmp + ") ");
        if (files[i] != null) {
          long fLen = files[i].getLength();
          if (fLen > 0) {
            DecimalFormat df = new DecimalFormat("000.0%");
            out.print(df.format(files[i].getDownloaded() * 1.0
                / fLen));
            out.println("\t" + files[i].getFile(true).getName());
          } else
            out.println("Info not available.");
        } else
View Full Code Here

    }

    private static void printStat(String name, AtomicLong value) {
        if (value.get() > 0) {
            DecimalFormat df = new DecimalFormat("###,###,###,###");
            out.println(name + "=" + df.format(CREATE_COUNT.get()));
        }
    }

}
View Full Code Here

      formatString.append('0');
    formatString.append(": ");
    final DecimalFormat format = new DecimalFormat(formatString.toString());
   
    StringBuffer retVal = new StringBuffer();
    retVal.append(format.format(0));
    int i = -1;
    for(int x = 0; x < value.length; x++) {
      if (++i == bytesPerLine) {
        retVal.append('\n');
        retVal.append(format.format(x));
View Full Code Here

    retVal.append(format.format(0));
    int i = -1;
    for(int x = 0; x < value.length; x++) {
      if (++i == bytesPerLine) {
        retVal.append('\n');
        retVal.append(format.format(x));
        i = 0;
      }
      retVal.append(toHex(value[x]));
      retVal.append(", ");
    }
View Full Code Here

      }
     
      oForm.setOpportunitytypeid((new Integer(oVO.getOpportunityTypeID())).toString());
      oForm.setProbabilityid((new Integer(oVO.getProbability())).toString());
      DecimalFormat currencyFormat = new DecimalFormat("###,###,##0.00");
      String actualAmount = currencyFormat.format(oVO.getActualAmount());
      oForm.setTotalamount(actualAmount);
     
      String forecast = currencyFormat.format(oVO.getForecastedAmount());
      oForm.setForecastedamount(forecast);
     
View Full Code Here

      oForm.setProbabilityid((new Integer(oVO.getProbability())).toString());
      DecimalFormat currencyFormat = new DecimalFormat("###,###,##0.00");
      String actualAmount = currencyFormat.format(oVO.getActualAmount());
      oForm.setTotalamount(actualAmount);
     
      String forecast = currencyFormat.format(oVO.getForecastedAmount());
      oForm.setForecastedamount(forecast);
     
      if (oVO.getCreateddate() != null) {
        Timestamp date = (Timestamp)oVO.getCreateddate();
       
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.