Code example for DecimalFormat

Methods: format, setDecimalSeparatorAlwaysShown, setMaximumFractionDigits, setMinimumFractionDigits

   * @param done the percentage to format (0.0 to 1.0) 
   * @param digits the number of digits past the decimal point 
   * @return a string representation of the percentage 
  public static String formatPercent(double done, int digits) {
    DecimalFormat percentFormat = new DecimalFormat("0.00%");
    double scale = Math.pow(10.0, digits+2);
    double rounded = Math.floor(done * scale);
    return percentFormat.format(rounded / scale);
   * Given an array of strings, return a comma-separated list of its elements. 
   * @param strs Array of strings 
   * @return Empty string if strs.length is 0, comma separated list of strings 
   * otherwise