No. The bits in value
provide data for format()
when it creates a string of characters, but the bits in value
are not changed.
It is not recommended that programs change the locale used by the Java virtual machine, since doing so may affect other Java programs that are running. But if you want to experiment, you can do this:
Locale.setDefault( Locale newLocale )
Here are some Locale
constants to use:
CANADA
, CHINA
, FRANCE
,
GERMANY
, UK
, and US
.
For others, look in the Java documentation.
This program should produce the same output no matter where
it is run:
import java.text.*; import java.util.Locale; class IODemoGermany { public static void main ( String[] args ) { Integer i = new Integer( 7654321 ); Double d = new Double ( 11000.0008 ); Locale.setDefault( Locale.GERMANY ); DecimalFormat numform = new DecimalFormat(); System.out.println( "Default Locale = " + Locale.getDefault() ); System.out.println( "integer = " + numform.format(i) + " double = " + numform.format(d) ); } }
The default locale remains set to the new locale (GERMANY in the above program) only as long as the Java virutal machine is running. When it starts up again (perhaps when you run another program) it will use the original default locale. To make a permanent change to the default locale you need to change some operating system parameters. This is not a good idea.
What do you suspect that the following fragment writes out (use your default locale):
DecimalFormat numform = new DecimalFormat(); System.out.println( "Third = " + numform.format(1.0/3.0) );