Java - Formatter class with Locale

Introduction

Formatter class uses the locale-specific formatting whenever it is applicable.

The locale argument of the format() method formats text in a locale-specific format.

The following code demonstrates the effects of locale-specific formatting.

Demo

import java.util.Date;
import java.util.Locale;

public class Main {
  public static void main(String[] args) {
    System.out.printf(Locale.US, "In US: %1$.2f %n", 12.89);
    System.out.printf(Locale.FRANCE, "In France: %1$.2f %n", 12.89);

    Date dt = new Date();
    System.out.printf(Locale.US, "In US: %tA %n", dt);
    System.out.printf(Locale.FRANCE, "In France: %tA %n", dt);

  }//  ww  w .ja  v a  2s.c  o  m
}

Result