Java Locale.toLanguageTag()

Syntax

Locale.toLanguageTag() has the following syntax.

public String toLanguageTag()

Example

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


//from   w  w w.  j ava 2  s  . c  om
import java.util.Locale;

public class Main {

   public static void main(String[] args) {
      Locale locale = new Locale("ENGLISH");

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

      System.out.println(locale.toLanguageTag());

   }
}

The code above generates the following result.