Skip to content

Instantly share code, notes, and snippets.

@stuart-marks
Created August 16, 2016 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuart-marks/da122da352e6091fa088d1a35cff4db0 to your computer and use it in GitHub Desktop.
Save stuart-marks/da122da352e6091fa088d1a35cff4db0 to your computer and use it in GitHub Desktop.
Decimal Separator
$ cat Printf.java
public class Printf {
public static void main(String[] args) {
System.out.println("Locale.getDefault()=" + java.util.Locale.getDefault());
System.out.printf("%.3f%n", 123.45);
}
}
$ javac Printf.java
$ java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
$ java Printf
Locale.getDefault()=en_US
123.450
$ java -Duser.country=DE -Duser.language=de Printf
Locale.getDefault()=de_DE
123,450
[switch JDK versions]
$ java -version
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+127)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+127, mixed mode)
$ java Printf
Locale.getDefault()=en_US
123.450
$ java -Duser.country=DE -Duser.language=de Printf
Locale.getDefault()=de_DE
123,450
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment