Format dates and numbers

public String FD(String strDate){
// Converts a date from 1900-01-01 to 01-01-1900 and vice versa ....
if ( strDate != null ) {
String newDate[];
String strNewDate = "";
int indx =0;

newDate = strDate.split("-",3);


for (indx = 2; indx >=0; indx-- )

strNewDate = strNewDate + newDate[indx] + "-";
return(strNewDate.substring(0, strNewDate.length() - 1));
}
else
return ("");
}

public String FC(String strMoney){
// Converts a string from 00000000,00 to 00.000.000.000,00

if ( strMoney != null ) {
BigDecimal amount = new BigDecimal(strMoney);

NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumFractionDigits(2);
nf.setMaximumFractionDigits(2);
String res = nf.format(amount);
return( res );
}
else
return ("");
}

No comments:

Post a Comment