| 21543 |
ashik.ali |
1 |
package com.spice.profitmandi.common.util;
|
|
|
2 |
|
|
|
3 |
import java.text.NumberFormat;
|
|
|
4 |
import java.util.Locale;
|
|
|
5 |
|
|
|
6 |
public class FormattingUtils {
|
|
|
7 |
|
|
|
8 |
private static Locale indianLocale = new Locale("en", "IN");
|
|
|
9 |
|
|
|
10 |
private NumberFormat currencyFormat;
|
|
|
11 |
|
|
|
12 |
public FormattingUtils(){
|
|
|
13 |
currencyFormat = NumberFormat.getNumberInstance(indianLocale);
|
|
|
14 |
currencyFormat.setMaximumFractionDigits(2);
|
|
|
15 |
currencyFormat.setMinimumFractionDigits(2);
|
|
|
16 |
currencyFormat.setMinimumIntegerDigits(1);
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
public FormattingUtils(int maximumFractionDigits){
|
|
|
20 |
currencyFormat = NumberFormat.getNumberInstance(indianLocale);
|
|
|
21 |
currencyFormat.setMaximumFractionDigits(maximumFractionDigits);
|
|
|
22 |
currencyFormat.setMinimumIntegerDigits(1);
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
public String formatPrice(double amount){
|
|
|
26 |
return currencyFormat.format(amount);
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
}
|