|
|
@ -538,20 +538,40 @@ public class Utils { |
|
|
|
return inputString.matches("^\\d+$"); |
|
|
|
} |
|
|
|
|
|
|
|
// public static String formatCurrency(String unformmatedCurrency) { |
|
|
|
// try { |
|
|
|
// unformmatedCurrency = unformmatedCurrency.replaceAll("\\.\\d*", ""); |
|
|
|
// Long longval; |
|
|
|
// if (unformmatedCurrency.contains(",")) { |
|
|
|
// unformmatedCurrency = unformmatedCurrency.replaceAll(",", ""); |
|
|
|
// } |
|
|
|
// longval = Long.parseLong(unformmatedCurrency); |
|
|
|
// |
|
|
|
// DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US); |
|
|
|
// formatter.applyPattern("#,###,###,###"); |
|
|
|
// return formatter.format(longval); |
|
|
|
// } catch (Exception e) { |
|
|
|
// e.printStackTrace(); |
|
|
|
// return unformmatedCurrency; |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
public static String formatCurrency(String unformmatedCurrency) { |
|
|
|
try { |
|
|
|
unformmatedCurrency = unformmatedCurrency.replaceAll("\\.\\d*", ""); |
|
|
|
Long longval; |
|
|
|
double decimalValue; |
|
|
|
if (unformmatedCurrency.contains(",")) { |
|
|
|
unformmatedCurrency = unformmatedCurrency.replaceAll(",", ""); |
|
|
|
} |
|
|
|
longval = Long.parseLong(unformmatedCurrency); |
|
|
|
decimalValue = Double.parseDouble(unformmatedCurrency); |
|
|
|
|
|
|
|
DecimalFormat formatter = new DecimalFormat("#,###,###.##"); |
|
|
|
|
|
|
|
String temp= formatter.format(decimalValue); |
|
|
|
return temp; |
|
|
|
|
|
|
|
DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US); |
|
|
|
formatter.applyPattern("#,###,###,###"); |
|
|
|
return formatter.format(longval); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
return unformmatedCurrency; |
|
|
|
} |
|
|
|
} |
|
|
|