Java Number Format Pattern getF(String tStr, String formate)

Here you can find the source of getF(String tStr, String formate)

Description

get F

License

Open Source License

Declaration

public static String getF(String tStr, String formate) 

Method Source Code


//package com.java2s;

import java.text.DecimalFormat;
import java.text.FieldPosition;

public class Main {

    private static DecimalFormat df = new DecimalFormat();

    public static String getF(String tStr, String formate) {
        try {/*from w  w w  .j a  v  a2s  .  c om*/
            df.applyPattern(formate);
            return format(tStr);
        } catch (Exception e) {
            return tStr;
        }
    }

    public static String format(String tStr) {
        StringBuffer sb = new StringBuffer();
        df.format(Double.valueOf(tStr).doubleValue(), sb, new FieldPosition(df.INTEGER_FIELD));
        return sb.toString();
    }
}

Related

  1. formatWith6Digits(String input)
  2. getBigDecimalFromString(String numericValue, String numberFormat)
  3. getDataFormat(final boolean grouped, final boolean isFloat, int declen)
  4. getDefaultDecimalFormat()
  5. getExponentialFormat(int precision)
  6. getFloatFormat()
  7. getFormat()
  8. getFormat(int decimals)
  9. getFormat(int nbDecimale)