Java Locale.getVariant()

Syntax

Locale.getVariant() has the following syntax.

public String getVariant()

Example

In the following code shows how to use Locale.getVariant() method.


/*from w w w  .  ja  v a 2 s .c om*/

import java.util.Locale;

public class Main {

   public static void main(String[] args) {
      Locale locale = new Locale("en", "US", "WIN");

      System.out.println("Locale:" + locale);

      // get variant and print it
      System.out.println("Language:" + locale.getVariant());
   }
}

The code above generates the following result.