private static String convertToken(final String token,final String arg1){
  if (!StringUtils.isNumber(arg1)) {
    return "";
  }
  final double value=Double.parseDouble(arg1);
  int decimalPoints=-1, minWidth=0;
  char decimal='.';
  boolean padd=false, floatDecimal=false;
  final StringBuilder sValue=new StringBuilder();
  final StringBuilder returnString=new StringBuilder();
  final char[] tokArray=token.toCharArray();
  if (tokArray[0] == '%') {
    int i=1;
    final int size=tokArray.length;
    loop:     while (i < size) {
switch (tokArray[i]) {
case ',':
switch (tokArray[++i]) {
case '0':
          decimal='.';
        break;
case '1':
      decimal='.';
    break;
case '2':
  decimal=',';
break;
case '3':
decimal=',';
break;
}
break;
case '+':
if (value > 0) {
returnString.append('+');
}
 else {
returnString.append('-');
}
break;
case ' ':
if (value > 0) {
returnString.append(' ');
}
 else {
returnString.append('-');
}
break;
case '0':
padd=true;
break;
case '#':
floatDecimal=true;
break;
case '.':
decimalPoints=Integer.parseInt(String.valueOf(tokArray[++i]));
break;
case 'd':
sValue.append((int)value);
if (padd) {
final int stringlen=returnString.length() + sValue.length();
if (stringlen < minWidth) {
for (int p=0; p < minWidth - stringlen; p++) {
returnString.append('0');
}
}
}
returnString.append(sValue);
break loop;
case 'f':
if (decimalPoints != -1) {
if (decimalPoints == 0) {
sValue.append((int)value);
}
 else {
final NumberFormat nf=NumberFormat.getInstance();
nf.setMinimumFractionDigits(decimalPoints);
nf.setMaximumFractionDigits(decimalPoints);
sValue.append(nf.format(value));
}
}
 else {
sValue.append((float)value);
}
if (floatDecimal && sValue.indexOf(".") != -1) {
sValue.append('.');
}
if (padd) {
final int stringlen=returnString.length() + sValue.length();
if (stringlen < minWidth) {
for (int p=0; p < minWidth - stringlen; p++) {
returnString.append('0');
}
}
}
String ssVal=sValue.toString();
ssVal=ssVal.replace('.',decimal);
returnString.append(ssVal);
break loop;
case 's':
sValue.append(value);
if (padd) {
final int stringlen=returnString.length() + sValue.length();
if (stringlen < minWidth) {
for (int p=0; p < minWidth - stringlen; p++) {
returnString.append('0');
}
}
}
returnString.append(sValue);
break loop;
case 'x':
final int valI=(int)(value);
final String retValS=Integer.toHexString(valI);
sValue.append(retValS);
if (padd) {
final int stringlen=returnString.length() + sValue.length();
if (stringlen < minWidth) {
for (int p=0; p < minWidth - stringlen; p++) {
returnString.append('0');
}
}
}
returnString.append(sValue);
break loop;
default :
minWidth=NumberUtils.parseInt(0,1,new byte[]{(byte)tokArray[i]});
break;
}
i++;
}
}
return returnString.toString();
}

private static String convertToken ( final String token , final String arg1 ) { if ( ! StringUtils . isNumber ( arg1 ) ) { return "" ; } final double value = Double . parseDouble ( arg1 ) ; int decimalPoints = - 1 , minWidth = 0 ; char decimal = '.' ; boolean padd = false , floatDecimal = false ; final StringBuilder sValue = new StringBuilder ( ) ; final StringBuilder returnString = new StringBuilder ( ) ; final char [ ] tokArray = token . toCharArray ( ) ; if ( tokArray [ 0 ] == '%' ) { int i = 1 ; final int size = tokArray . length ; loop : while ( i < size ) { switch ( tokArray [ i ] ) { case ',' : switch ( tokArray [ ++ i ] ) { case '0' : decimal = '.' ; break ; case '1' : decimal = '.' ; break ; case '2' : decimal = ',' ; break ; case '3' : decimal = ',' ; break ; } break ; case '+' : if ( value > 0 ) { returnString . append ( '+' ) ; } else { returnString . append ( '-' ) ; } break ; case ' ' : if ( value > 0 ) { returnString . append ( ' ' ) ; } else { returnString . append ( '-' ) ; } break ; case '0' : padd = true ; break ; case '#' : floatDecimal = true ; break ; case '.' : decimalPoints = Integer . parseInt ( String . valueOf ( tokArray [ ++ i ] ) ) ; break ; case 'd' : sValue . append ( ( int ) value ) ; if ( padd ) { final int stringlen = returnString . length ( ) + sValue . length ( ) ; if ( stringlen < minWidth ) { for ( int p = 0 ; p < minWidth - stringlen ; p ++ ) { returnString . append ( '0' ) ; } } } returnString . append ( sValue ) ; break loop ; case 'f' : if ( decimalPoints != - 1 ) { if ( decimalPoints == 0 ) { sValue . append ( ( int ) value ) ; } else { final NumberFormat nf = NumberFormat . getInstance ( ) ; nf . setMinimumFractionDigits ( decimalPoints ) ; nf . setMaximumFractionDigits ( decimalPoints ) ; sValue . append ( nf . format ( value ) ) ; } } else { sValue . append ( ( float ) value ) ; } if ( floatDecimal && sValue . indexOf ( "." ) != - 1 ) { sValue . append ( '.' ) ; } if ( padd ) { final int stringlen = returnString . length ( ) + sValue . length ( ) ; if ( stringlen < minWidth ) { for ( int p = 0 ; p < minWidth - stringlen ; p ++ ) { returnString . append ( '0' ) ; } } } String ssVal = sValue . toString ( ) ; ssVal = ssVal . replace ( '.' , decimal ) ; returnString . append ( ssVal ) ; break loop ; case 's' : sValue . append ( value ) ; if ( padd ) { final int stringlen = returnString . length ( ) + sValue . length ( ) ; if ( stringlen < minWidth ) { for ( int p = 0 ; p < minWidth - stringlen ; p ++ ) { returnString . append ( '0' ) ; } } } returnString . append ( sValue ) ; break loop ; case 'x' : final int valI = ( int ) ( value ) ; final String retValS = Integer . toHexString ( valI ) ; sValue . append ( retValS ) ; if ( padd ) { final int stringlen = returnString . length ( ) + sValue . length ( ) ; if ( stringlen < minWidth ) { for ( int p = 0 ; p < minWidth - stringlen ; p ++ ) { returnString . append ( '0' ) ; } } } returnString . append ( sValue ) ; break loop ; default : minWidth = NumberUtils . parseInt ( 0 , 1 , new byte [ ] { ( byte ) tokArray [ i ] } ) ; break ; } i ++ ; } } return returnString . toString ( ) ; }
for the use of the printf commend
