LocalePreferences
@RequiresApi(value = VERSION_CODES.LOLLIPOP)
public final class LocalePreferences
Provides friendly APIs to get the user's locale preferences. The data can refer to external/cldr/common/main/en.xml.
Summary
Nested types |
|---|
public class LocalePreferences.CalendarTypeAPIs to get the user's preference of Calendar. |
public class LocalePreferences.FirstDayOfWeekAPIs to get the user's preference of the first day of week. |
public class LocalePreferences.HourCycleAPIs to get the user's preference of the hour cycle. |
public class LocalePreferences.TemperatureUnitAPIs to get the user's preference of temperature unit. |
Public methods |
|
|---|---|
static @NonNull String |
Return the user's preference of the calendar type which is from |
static @NonNull String |
getCalendarType(@NonNull Locale locale)Return the calendar type of the inputted |
static @NonNull String |
getCalendarType(boolean resolved)Return the user's preference of the calendar type which is from |
static @NonNull String |
getCalendarType(@NonNull Locale locale, boolean resolved)Return the calendar type of the inputted |
static @NonNull String |
Return the user's preference of the first day of week which is from |
static @NonNull String |
getFirstDayOfWeek(@NonNull Locale locale)Return the first day of week of the inputted |
static @NonNull String |
getFirstDayOfWeek(boolean resolved)Return the user's preference of the first day of week which is from |
static @NonNull String |
getFirstDayOfWeek(@NonNull Locale locale, boolean resolved)Return the first day of week of the inputted |
static @NonNull String |
Return the user's preference of the hour cycle which is from |
static @NonNull String |
getHourCycle(@NonNull Locale locale)Return the hour cycle setting of the inputted |
static @NonNull String |
getHourCycle(boolean resolved)Return the user's preference of the hour cycle which is from |
static @NonNull String |
getHourCycle(@NonNull Locale locale, boolean resolved)Return the hour cycle setting of the inputted |
static @NonNull String |
Return the user's preference of the temperature unit which is from |
static @NonNull String |
getTemperatureUnit(@NonNull Locale locale)Return the temperature unit of the inputted |
static @NonNull String |
getTemperatureUnit(boolean resolved)Return the user's preference of the temperature unit which is from |
static @NonNull String |
getTemperatureUnit(@NonNull Locale locale, boolean resolved)Return the temperature unit of the inputted |
Public methods
getCalendarType
public static @NonNull String getCalendarType()
Return the user's preference of the calendar type which is from getDefault. 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
public static @NonNull String getCalendarType(@NonNull Locale locale)
Return the calendar type of the inputted Locale. The returned result is resolved and based on the input Locale settings. It is one of the strings defined in {@see CalendarType}, e.g. CalendarType#CHINESE.
getCalendarType
public static @NonNull String getCalendarType(boolean resolved)
Return the user's preference of the calendar type which is from getDefault, e.g. CalendarType#CHINESE.
| Parameters | |
|---|---|
boolean resolved |
If the |
| Returns | |
|---|---|
@NonNull String |
|
getCalendarType
public static @NonNull String getCalendarType(@NonNull Locale locale, boolean resolved)
Return the calendar type of the inputted Locale, e.g. CalendarType#CHINESE.
| Parameters | |
|---|---|
@NonNull Locale locale |
The |
boolean resolved |
If the given |
| Returns | |
|---|---|
@NonNull String |
|
getFirstDayOfWeek
public static @NonNull String getFirstDayOfWeek()
Return the user's preference of the first day of week which is from getDefault. 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
public static @NonNull String getFirstDayOfWeek(@NonNull Locale locale)
Return the first day of week of the inputted Locale. 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
public static @NonNull String getFirstDayOfWeek(boolean resolved)
Return the user's preference of the first day of week which is from getDefault, e.g. FirstDayOfWeek#SUNDAY.
| Parameters | |
|---|---|
boolean resolved |
If the |
| Returns | |
|---|---|
@NonNull String |
|
getFirstDayOfWeek
public static @NonNull String getFirstDayOfWeek(@NonNull Locale locale, boolean resolved)
Return the first day of week of the inputted Locale, e.g. FirstDayOfWeek#SUNDAY.
| Parameters | |
|---|---|
@NonNull Locale locale |
The |
boolean resolved |
If the given |
| Returns | |
|---|---|
@NonNull String |
|
getHourCycle
public static @NonNull String getHourCycle()
Return the user's preference of the hour cycle which is from getDefault. 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
public static @NonNull String getHourCycle(@NonNull Locale locale)
Return the hour cycle setting of the inputted Locale. 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
public static @NonNull String getHourCycle(boolean resolved)
Return the user's preference of the hour cycle which is from getDefault, e.g. HourCycle#H11.
| Parameters | |
|---|---|
boolean resolved |
If the |
| Returns | |
|---|---|
@NonNull String |
|
getHourCycle
public static @NonNull String getHourCycle(@NonNull Locale locale, boolean resolved)
Return the hour cycle setting of the inputted Locale. E.g. "en-US-u-hc-h23".
| Parameters | |
|---|---|
@NonNull Locale locale |
The |
boolean resolved |
If the given |
| Returns | |
|---|---|
@NonNull String |
|
getTemperatureUnit
public static @NonNull String getTemperatureUnit()
Return the user's preference of the temperature unit which is from getDefault. 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
public static @NonNull String getTemperatureUnit(@NonNull Locale locale)
Return the temperature unit of the inputted Locale. It is one of the strings defined in {@see TemperatureUnit}, e.g. TemperatureUnit#FAHRENHEIT.
getTemperatureUnit
public static @NonNull String getTemperatureUnit(boolean resolved)
Return the user's preference of the temperature unit which is from getDefault, e.g. TemperatureUnit#FAHRENHEIT.
| Parameters | |
|---|---|
boolean resolved |
If the |
| Returns | |
|---|---|
@NonNull String |
|
getTemperatureUnit
public static @NonNull String getTemperatureUnit(@NonNull Locale locale, boolean resolved)
Return the temperature unit of the inputted Locale. E.g. "fahrenheit"
| Parameters | |
|---|---|
@NonNull Locale locale |
The |
boolean resolved |
If the given |
| Returns | |
|---|---|
@NonNull String |
|