So the quick and dirty fix is to convert the BigDecimal into a string (using toString), grab the last four numbers, and put xxxx-xxxx-xxxx- in front of it.
DecimalFormat df = new DecimalFormat();
df.applyPattern("#,##,###,####");
BigDecimal bd = new BigDecimal("1111111111111111");
System.out.println("Result :"+df.format(bd.longValue()).replace(',','-'));;
here i have tried to use java.text.DecimalFormat class
here the replace(',','-') is used, since i was not able to use '-' as seperator in the pattern.
regards
vikrant
0
salasadiAuthor Commented:
Vikrant ...
Thanks for the example. this displays the number as 11111-11111-11111-11111 I want ONLY the 4 digits displays and the rest will be xxxx-xxxx-xxxx-1111
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
BigDecimal bd = new BigDecimal("12341234123412
String cNum = bd.toString();
String filteredCnum = "xxxx-xxxx-xxxx-" + cNum.substring(cNum.length