# LocalePreferences

# LocalePreferences

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/text/util/LocalePreferences.java+class:androidx.core.text.util.LocalePreferences)  
Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/text/util/LocalePreferences "View this page in Java")

<br />

```
@RequiresApi(value = VERSION_CODES.LOLLIPOP)
class LocalePreferences
```

<br />

*** ** * ** ***

Provides friendly APIs to get the user's locale preferences. The data can refer to external/cldr/common/main/en.xml.

## Summary

|                                                                                                ### Nested types                                                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[LocalePreferences.CalendarType](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.CalendarType) APIs to get the user's preference of Calendar.                  |
| `class `[LocalePreferences.FirstDayOfWeek](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.FirstDayOfWeek) APIs to get the user's preference of the first day of week. |
| `class `[LocalePreferences.HourCycle](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.HourCycle) APIs to get the user's preference of the hour cycle.                  |
| `class `[LocalePreferences.TemperatureUnit](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.TemperatureUnit) APIs to get the user's preference of temperature unit.    |

|                                      ### Public functions                                       |
|-------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getCalendarType](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getCalendarType())`()` Return the user's preference of the calendar type which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)).                                                                                                                                                       |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getCalendarType](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getCalendarType(java.util.Locale))`(locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)`)` Return the calendar type of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html).                                                                                                                       |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getCalendarType](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getCalendarType(boolean))`(resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Return the user's preference of the calendar type which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)), e.g.                                            |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getCalendarType](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getCalendarType(java.util.Locale,boolean))`(locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)`, resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Return the calendar type of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html), e.g.         |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getFirstDayOfWeek](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getFirstDayOfWeek())`()` Return the user's preference of the first day of week which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)).                                                                                                                                               |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getFirstDayOfWeek](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getFirstDayOfWeek(java.util.Locale))`(locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)`)` Return the first day of week of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html).                                                                                                               |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getFirstDayOfWeek](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getFirstDayOfWeek(boolean))`(resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Return the user's preference of the first day of week which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)), e.g.                                    |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getFirstDayOfWeek](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getFirstDayOfWeek(java.util.Locale,boolean))`(locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)`, resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Return the first day of week of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html), e.g. |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getHourCycle](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getHourCycle())`()` Return the user's preference of the hour cycle which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)).                                                                                                                                                                |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getHourCycle](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getHourCycle(java.util.Locale))`(locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)`)` Return the hour cycle setting of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html).                                                                                                                        |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getHourCycle](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getHourCycle(boolean))`(resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Return the user's preference of the hour cycle which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)), e.g.                                                     |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getHourCycle](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getHourCycle(java.util.Locale,boolean))`(locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)`, resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Return the hour cycle setting of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html).               |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getTemperatureUnit](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getTemperatureUnit())`()` Return the user's preference of the temperature unit which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)).                                                                                                                                              |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getTemperatureUnit](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getTemperatureUnit(java.util.Locale))`(locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)`)` Return the temperature unit of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html).                                                                                                              |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getTemperatureUnit](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getTemperatureUnit(boolean))`(resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Return the user's preference of the temperature unit which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)), e.g.                                   |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getTemperatureUnit](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences#getTemperatureUnit(java.util.Locale,boolean))`(locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)`, resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Return the temperature unit of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html).     |

## Public functions

### getCalendarType

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getCalendarType(): String
```

Return the user's preference of the calendar type which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)). The returned result is resolved and bases on the`Locale#getDefault(Locale.Category)`settings. It is one of the strings defined in {@see CalendarType}, e.g.`CalendarType#CHINESE`.  

### getCalendarType

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getCalendarType(locale: Locale): String
```

Return the calendar type of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html). The returned result is resolved and based on the input[Locale](https://developer.android.com/reference/java/util/Locale.html)settings. It is one of the strings defined in {@see CalendarType}, e.g.`CalendarType#CHINESE`.  

### getCalendarType

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getCalendarType(resolved: Boolean): String
```

Return the user's preference of the calendar type which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)), e.g.`CalendarType#CHINESE`.  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | If the`Locale#getDefault(Locale.Category)`contains calendar type subtag, this argument is ignored. If the`Locale#getDefault(Locale.Category)`doesn't contain calendar type subtag and the resolved argument is true, this function tries to find the default calendar type for the`Locale#getDefault(Locale.Category)`. If the`Locale#getDefault(Locale.Category)`doesn't contain calendar type subtag and the resolved argument is false, this function returns empty string , i.e.`CalendarType#DEFAULT`. |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [CalendarType.CalendarTypes](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.CalendarType.CalendarTypes)If the malformed calendar type format was specified in the calendar type subtag, e.g. en-US-u-ca-calendar, this function returns empty string, i.e.`CalendarType#DEFAULT`. |

### getCalendarType

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getCalendarType(locale: Locale, resolved: Boolean): String
```

Return the calendar type of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html), e.g.`CalendarType#CHINESE`.  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)               | The[Locale](https://developer.android.com/reference/java/util/Locale.html)to get the calendar type.                                                                                                                                                                                                                                                                                                               |
| `resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | If the given`Locale`contains calendar type subtag, this argument is ignored. If the given`Locale`doesn't contain calendar type subtag and the resolved argument is true, this function tries to find the default calendar type for the given`Locale`. If the given`Locale`doesn't contain calendar type subtag and the resolved argument is false, this function return empty string, i.e.`CalendarType#DEFAULT`. |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [CalendarType.CalendarTypes](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.CalendarType.CalendarTypes)If the malformed calendar type format was specified in the calendar type subtag, e.g. en-US-u-ca-calendar, this function returns empty string, i.e.`CalendarType#DEFAULT`. |

### getFirstDayOfWeek

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getFirstDayOfWeek(): String
```

Return the user's preference of the first day of week which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)). The returned result is resolved and bases on the`Locale#getDefault(Locale.Category)`settings. It is one of the strings defined in {@see FirstDayOfWeek}, e.g.`FirstDayOfWeek#SUNDAY`.  

### getFirstDayOfWeek

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getFirstDayOfWeek(locale: Locale): String
```

Return the first day of week of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html). The returned result is resolved and based on the input`Locale`settings. It is one of the strings defined in {@see FirstDayOfWeek}, e.g.`FirstDayOfWeek#SUNDAY`.  

### getFirstDayOfWeek

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getFirstDayOfWeek(resolved: Boolean): String
```

Return the user's preference of the first day of week which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)), e.g.`FirstDayOfWeek#SUNDAY`.  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | If the`Locale#getDefault(Locale.Category)`contains first day of week subtag, this argument is ignored. If the`Locale#getDefault(Locale.Category)`doesn't contain first day of week subtag and the resolved argument is true, this function tries to find the default first day of week for the`Locale#getDefault(Locale.Category)`. If the`Locale#getDefault(Locale.Category)`doesn't contain first day of week subtag and the resolved argument is false, this function returns empty string , i.e.`FirstDayOfWeek#DEFAULT`. |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [FirstDayOfWeek.Days](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.FirstDayOfWeek.Days)If the malformed first day of week format was specified in the first day of week subtag, e.g. en-US-u-fw-days, this function returns empty string, i.e.`FirstDayOfWeek#DEFAULT`. |

### getFirstDayOfWeek

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getFirstDayOfWeek(locale: Locale, resolved: Boolean): String
```

Return the first day of week of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html), e.g.`FirstDayOfWeek#SUNDAY`.  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)               | The[Locale](https://developer.android.com/reference/java/util/Locale.html)to get the first day of week.                                                                                                                                                                                                                                                                                                                             |
| `resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | If the given`Locale`contains first day of week subtag, this argument is ignored. If the given`Locale`doesn't contain first day of week subtag and the resolved argument is true, this function tries to find the default first day of week for the given`Locale`. If the given`Locale`doesn't contain first day of week subtag and the resolved argument is false, this function return empty string, i.e.`FirstDayOfWeek#DEFAULT`. |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [FirstDayOfWeek.Days](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.FirstDayOfWeek.Days)If the malformed first day of week format was specified in the first day of week subtag, e.g. en-US-u-fw-days, this function returns empty string, i.e.`FirstDayOfWeek#DEFAULT`. |

### getHourCycle

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getHourCycle(): String
```

Return the user's preference of the hour cycle which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)). The returned result is resolved and bases on the`Locale#getDefault(Locale.Category)`. It is one of the strings defined in {@see HourCycle}, e.g.`HourCycle#H11`.  

### getHourCycle

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getHourCycle(locale: Locale): String
```

Return the hour cycle setting of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html). The returned result is resolved and based on the input`Locale`. It is one of the strings defined in {@see HourCycle}, e.g.`HourCycle#H11`.  

### getHourCycle

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getHourCycle(resolved: Boolean): String
```

Return the user's preference of the hour cycle which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)), e.g.`HourCycle#H11`.  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | If the`Locale#getDefault(Locale.Category)`contains hour cycle subtag, this argument is ignored. If the`Locale#getDefault(Locale.Category)`doesn't contain hour cycle subtag and the resolved argument is true, this function tries to find the default hour cycle for the`Locale#getDefault(Locale.Category)`. If the`Locale#getDefault(Locale.Category)`doesn't contain hour cycle subtag and the resolved argument is false, this function returns empty string , i.e.`HourCycle#DEFAULT`. |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [HourCycle.HourCycleTypes](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.HourCycle.HourCycleTypes)If the malformed hour cycle format was specified in the hour cycle subtag, e.g. en-US-u-hc-h32, this function returns empty string, i.e.`HourCycle#DEFAULT`. |

### getHourCycle

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getHourCycle(locale: Locale, resolved: Boolean): String
```

Return the hour cycle setting of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html). E.g. "en-US-u-hc-h23".  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)               | The`Locale`to get the hour cycle.                                                                                                                                                                                                                                                                                                                                                                  |
| `resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | If the given`Locale`contains hour cycle subtag, this argument is ignored. If the given`Locale`doesn't contain hour cycle subtag and the resolved argument is true, this function tries to find the default hour cycle for the given`Locale`. If the given`Locale`doesn't contain hour cycle subtag and the resolved argument is false, this function return empty string, i.e.`HourCycle#DEFAULT`. |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [HourCycle.HourCycleTypes](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.HourCycle.HourCycleTypes)If the malformed hour cycle format was specified in the hour cycle subtag, e.g. en-US-u-hc-h32, this function returns empty string, i.e.`HourCycle#DEFAULT`. |

### getTemperatureUnit

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getTemperatureUnit(): String
```

Return the user's preference of the temperature unit which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)). The returned result is resolved and bases on the`Locale#getDefault(Locale.Category)`settings. It is one of the strings defined in {@see TemperatureUnit}, e.g.`TemperatureUnit#FAHRENHEIT`.  

### getTemperatureUnit

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getTemperatureUnit(locale: Locale): String
```

Return the temperature unit of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html). It is one of the strings defined in {@see TemperatureUnit}, e.g.`TemperatureUnit#FAHRENHEIT`.  

### getTemperatureUnit

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getTemperatureUnit(resolved: Boolean): String
```

Return the user's preference of the temperature unit which is from[getDefault](https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)), e.g.`TemperatureUnit#FAHRENHEIT`.  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | If the`Locale#getDefault(Locale.Category)`contains temperature unit subtag, this argument is ignored. If the`Locale#getDefault(Locale.Category)`doesn't contain temperature unit subtag and the resolved argument is true, this function tries to find the default temperature unit for the`Locale#getDefault(Locale.Category)`. If the`Locale#getDefault(Locale.Category)`doesn't contain temperature unit subtag and the resolved argument is false, this function returns empty string , i.e.`TemperatureUnit#DEFAULT`. |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [TemperatureUnit.TemperatureUnits](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.TemperatureUnit.TemperatureUnits)If the malformed temperature unit format was specified in the temperature unit subtag, e.g. en-US-u-mu-temperature, this function returns empty string, i.e.`TemperatureUnit#DEFAULT`. |

### getTemperatureUnit

Added in[1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)  

```
java-static fun getTemperatureUnit(locale: Locale, resolved: Boolean): String
```

Return the temperature unit of the inputted[Locale](https://developer.android.com/reference/java/util/Locale.html). E.g. "fahrenheit"  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)               | The[Locale](https://developer.android.com/reference/java/util/Locale.html)to get the temperature unit.                                                                                                                                                                                                                                                                                                                           |
| `resolved: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | If the given`Locale`contains temperature unit subtag, this argument is ignored. If the given`Locale`doesn't contain temperature unit subtag and the resolved argument is true, this function tries to find the default temperature unit for the given`Locale`. If the given`Locale`doesn't contain temperature unit subtag and the resolved argument is false, this function return empty string, i.e.`TemperatureUnit#DEFAULT`. |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [TemperatureUnit.TemperatureUnits](https://developer.android.com/reference/kotlin/androidx/core/text/util/LocalePreferences.TemperatureUnit.TemperatureUnits)If the malformed temperature unit format was specified in the temperature unit subtag, e.g. en-US-u-mu-temperature, this function returns empty string, i.e.`TemperatureUnit#DEFAULT`. |