Java.util.Locale.getVariant() Method


Advertisements


Description

The java.util.Locale.getVariant() method returns the variant code for this locale.

Declaration

Following is the declaration for java.util.Locale.getVariant() method

public String getVariant()

Parameters

NA

Return Value

This method does not return a value.

Exception

NA

Example

The following example shows the usage of java.util.Locale.getVariant() method.

Live Demo
package com.tutorialspoint;

import java.util.*;

public class LocaleDemo {
   public static void main(String[] args) {

      // create a new locale
      Locale locale = new Locale("en", "US", "WIN");

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

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

Let us compile and run the above program, this will produce the following result −

Locale:en_US_WIN
Language:WIN

java_util_locale.htm

Advertisements