public static final void format(StringBuilder sb, double v, String format)
    {
        sb.append(String.format(Locale.US, format, v));
        int length = sb.length();
        while (true)
        {
            char cc = sb.charAt(length-1);
            if (cc == '.')
            {
                length--;
                break;
            }
            if (cc != '0')
            {
                break;
            }
            length--;
        }
        sb.setLength(length);
    }
public static final void format ( StringBuilder sb , double v , String format ) { sb . append ( String . format ( Locale . US , format , v ) ) ; int length = sb . length ( ) ; while ( true ) { char cc = sb . charAt ( length - 1 ) ; if ( cc == '.' ) { length -- ; break ; } if ( cc != '0' ) { break ; } length -- ; } sb . setLength ( length ) ; }
Appends value to StringBuilder so that it takes minimum space still
preserving precision using given decimal format.
<p>Note! Decimal separator is '.'.
@param sb
@param v
@param format