{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

Locale

public final class Locale


A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user. For example, displaying a number is a locale-sensitive operation— the number should be formatted according to the customs and conventions of the user's native country, region, or culture.

See also
TextStyle
SpanStyle

Summary

Nested types

public static class Locale.Companion

Public constructors

Locale(@NonNull String languageTag)

Create Locale object from a language tag.

Public methods

boolean
equals(Object other)
final @NonNull String

The ISO 639 compliant language code.

final @NonNull String

The ISO 3166 compliant region code.

final @NonNull String

The ISO 15924 compliant 4-letter script code.

int
final @NonNull String

Returns a IETF BCP47 compliant language tag representation of this Locale.

@NonNull String

Public constructors

Locale

public Locale(@NonNull String languageTag)

Create Locale object from a language tag.

Parameters
@NonNull String languageTag

A IETF BCP47 compliant language tag.

Returns
Locale

a locale object

Public methods

equals

public boolean equals(Object other)

getLanguage

public final @NonNull String getLanguage()

The ISO 639 compliant language code.

getRegion

public final @NonNull String getRegion()

The ISO 3166 compliant region code.

getScript

public final @NonNull String getScript()

The ISO 15924 compliant 4-letter script code.

hashCode

public int hashCode()

toLanguageTag

public final @NonNull String toLanguageTag()

Returns a IETF BCP47 compliant language tag representation of this Locale.

Returns
@NonNull String

A IETF BCP47 compliant language tag.

toString

public @NonNull String toString()