Anda bisa meneruskan Lokal tambahan ke java.lang.String.format serta ke java.io.PrintStream.printf (misalnya System.out.printf ()):
import java.util.Locale;
public class PrintfLocales {
public static void main(String args[]) {
System.out.printf("%.2f: Default locale\n", 3.1415926535);
System.out.printf(Locale.GERMANY, "%.2f: Germany locale\n", 3.1415926535);
System.out.printf(Locale.US, "%.2f: US locale\n", 3.1415926535);
}
}
Ini menghasilkan yang berikut (di PC saya):
$ java PrintfLocales
3.14: Default locale
3,14: Germany locale
3.14: US locale
Lihat String.format di Java API.