Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Lambodar Eng.   on Feb 11 In Java Category.

  
Question Answered By: Abana Cohen   on Feb 11

call the below method to change English numbers to Farsi numbers. It works well.

public static String convertDigitsToFarsi(String input) {
NumberFormat nf = NumberFormat.getInstance();
if (nf instanceof DecimalFormat) {
DecimalFormat df = (DecimalFormat) nf;
DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();

dfs.setZeroDigit('\u0660');
df.setDecimalFormatSymbols(dfs);
}

char[] cs = input.toCharArray();
for (int i = 0; i < cs.length; i++) {
int j = "0123456789".indexOf(cs[i]);
if (j != -1) {
cs[i] = nf.format(new Long(cs[i] + "")).toCharArray()[0];
}
}

return new String(cs);
}

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Original Nazanin Fonts (True Type) Or get search suggestion and latest updates.


Tagged: