Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with NumberFormat

 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am unable to convert the format of the number to different locale. I have attached the program and sample output. Can any one help in this one.

Program:
---------------------

package com.srinivas.scea.test;

import java.text.NumberFormat;
import java.util.Locale;

import sun.security.krb5.internal.ktab.l;

public class NumberFormatTest {
public static void main(String s[])
{
try{
java.util.Locale locale=Locale.getDefault();
NumberFormat numberFormat= NumberFormat.getNumberInstance(locale);
System.out.println(numberFormat.format(123456));
locale=new Locale("hi","IN");
System.out.println("Count "+locale.getCountry());
System.out.println("Language " +locale.getDisplayLanguage());
numberFormat=NumberFormat.getNumberInstance(locale);
System.out.println(numberFormat.format(123456));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}



-------------------------

Output :
-----------------------

123,456
Count IN
Language Hindi
???,???

---------------

Problem: When I try to convert the format to INDIA locale, it is giving ???,???.

Thank you,
 
Srinivas Kalvala
Ranch Hand
Posts: 257
Firefox Browser Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please ignore unnecessary imports in that program.

Thank you.
 
sai maddikay
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could be that the system should support the Hindi font to get the numbers displayed. did you try some other locale like en_US or en_GB?

jagi
[ August 03, 2006: Message edited by: jagi jagi ]
 
Santiago Urrizola
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
happens the same to me, could you try to put this outupt in a jsp ? and set the apropiated encoding ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic