Wednesday, July 20, 2016

Convert amount to indian rupees :

Convert amount to indian rupees : 

double totalinvestmentabilityamount = Double.parseDouble(totalamount);
String totalinvestmentabilityamount1=formatt(totalinvestmentabilityamount);


we should add this methods in our servlet:


public static String formatt(double value) {
 LogLevel.DEBUG(5,new Throwable(),"jhansi value:"+value );

    if(value < 1000) {
        return formatt("###", value);
    } else {
        double hundreds = value % 1000;
        int other = (int) (value / 1000);
        return formatt(",##", other) + ',' + formatt("000", hundreds);
    }
}

private static String formatt(String pattern, Object value) {
    return new DecimalFormat(pattern).format(value);
}

If total amount is 2003763714 it will display in indian rupee format as 2,00,37,63,714 

No comments:

Post a Comment