permaculture playing cards*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Problem with NumberFormat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Problem with NumberFormat " Watch "Problem with NumberFormat " New topic
Author

Problem with NumberFormat

Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257

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

Joined: Oct 20, 2005
Posts: 257

Please ignore unnecessary imports in that program.

Thank you.
sai maddikay
Greenhorn

Joined: Jul 03, 2006
Posts: 14
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

Joined: Apr 27, 2006
Posts: 172
happens the same to me, could you try to put this outupt in a jsp ? and set the apropiated encoding ?


Santiago Urrizola : La Plata - Argentina<br />SCEA (89%-92%)<br /><a href="http://gpitech.wordpress.com/" target="_blank" rel="nofollow">http://gpitech.wordpress.com/</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with NumberFormat