Community
Participate
Working Groups
Eclipse build number: I200405140800 CDT build number: 200405121551 TestCase number: QE_TestCase_P1_I18N211, QE_TestCase_P1_I18N212 Test Case: 1. Change the locale to Spanish from control panel. 2. Restart eclipse & create a Java or C/C++ project. Create a file under the project and add code to it such that the file size exceeds 1000 bytes. 3. Right click on file and go to Properties. The file size specified there is not formatted according to the locale selected. 4. Go to Windows->Show view->Properties. The file size is not number formatted in the properties view for the locale as well.
We get this value from the virtual machine (Long.toString(localFile.length()) so the issue is with the virtual machine.
Marking WONTFIX as there is nothing we can do.
The way numbers are displayed should pick up on the locale setting using Locale sensitive APIs. In Java, there are 2 ways: NumberFormat, or if the number is embedded in a string retrieved through a resource bundle, use MessageFormat. Like this: public class TestSize { public static void main(String[] args) { File localFile=new File ("test"); long len = localFile.length(); // use NumberFormat by itself NumberFormat nf = NumberFormat.getInstance(); String lenStr=nf.format(len); System.out.println ("NumberFormat: "+ lenStr); // or we can mix NumberFormat with MessageFormat System.out.println ("MessageFormat: "+getFormattedString("key", new Long(len))); //$NON-NLS-1$ } public static String getFormattedString(String key, Long arg) { return MessageFormat.format(getString(key), new Object[] { arg }); } public static String getString (String key) { return ("The file size is: {0, number, integer} {0, choice, 1#byte|2#bytes}"); } } The output would then be (for US English locale): NumberFormat: 7,360 MessageFormat: The file size is: 7,360 bytes
Reopening to implement Tanyas suggestions.
Fixed in build >20070628. Thanks for the contribution Tanya.
Verified in I20070807-0010