Decimal format without comma Like (2000.00)
public class DoubleValueFormate {
static DecimalFormat formatter = new DecimalFormat("0.00");
static DecimalFormat threeDigitformatter = new DecimalFormat("0.000");
static DecimalFormat fourDigitformatter = new DecimalFormat("0.0000");
Double value=0.0;
static public String getValue(String value) {
if(value.equalsIgnoreCase("null")|| value.equalsIgnoreCase(""))
{
return "";
}
else
{
double doubleValurFormate = Double.parseDouble(value);
return formatter.format(doubleValurFormate);
}
}
static public String getValue3Digit(String value) {
if(value.equalsIgnoreCase("null")|| value.equalsIgnoreCase(""))
{
return "";
}
else
{
double doubleValurFormate = Double.parseDouble(value);
return threeDigitformatter.format(doubleValurFormate);
}
}
static public String getValue4Digit(String value) {
if(value.equalsIgnoreCase("null")|| value.equalsIgnoreCase(""))
{
return "";
}
else
{
double doubleValurFormate = Double.parseDouble(value);
return fourDigitformatter.format(doubleValurFormate);
}
}
}
Decimal format with comma Like (2,00,000,000.00)
public class NumberForamteClass {
static NumberFormat formatter = NumberFormat.getNumberInstance();
public static String get4Digit(String value)
{
formatter.setMinimumFractionDigits(4);
formatter.setMaximumFractionDigits(4);
if(value.equalsIgnoreCase(""))
{
return"";
}
else
{
return ""+formatter.format(Double.parseDouble(value));
}
}
public static String get3Digit(String value)
{
formatter.setMinimumFractionDigits(3);
formatter.setMaximumFractionDigits(3);
if(value.equalsIgnoreCase(""))
{
return"";
}
else
{
return ""+formatter.format(Double.parseDouble(value));
}
}
}
This comment has been removed by a blog administrator.
ReplyDeleteIt is very useful for my app so thank you
ReplyDeletethank you
Deletenice tutorial. it help me so much.....Thanks
ReplyDelete