public final class LocaleUtil
extends java.lang.Object
Locale.setDefault(Locale)
and
TimeZone.setDefault(TimeZone)
methods, because the locale/time zone specific handling of certain office documents - maybe for different time zones / locales ... - shouldn't affect other java components. The settings are saved in a
ThreadLocal
, so they only apply to the current thread and can't be set globally.
(此实用程序类用于在 JDK 内部 Locale.setDefault(Locale) 和 TimeZone.setDefault(TimeZone) 方法之外设置区域设置和时区设置,因为特定办公文档的区域设置/时区特定处理 - 可能针对不同的时区/locales ... - 不应影响其他 java 组件。设置保存在 ThreadLocal 中,因此它们仅适用于当前线程,不能全局设置。)
Modifier and Type | Field and Description |
---|---|
static java.nio.charset.Charset |
CHARSET_1252
Default encoding for unknown byte encodings of native files (at least it's better than to rely on a platform dependent encoding for legacy stuff ...)
(本机文件的未知字节编码的默认编码(至少它比依赖于平台相关的遗留编码更好......))
|
static java.util.TimeZone |
TIMEZONE_UTC
Excel doesn't store TimeZone information in the file, so if in doubt, use UTC to perform calculations
(Excel 不会在文件中存储时区信息,因此如果有疑问,请使用 UTC 执行计算)
|
Modifier and Type | Method and Description |
---|---|
static int |
getDefaultCodePageFromLCID(int lcid)
Get default code page from LCID value
(从 LCID 值获取默认代码页)
|
static java.util.Calendar |
getLocaleCalendar() |
static java.util.Calendar |
getLocaleCalendar(int year, int month, int day)
Convenience method - month is 0-based as in java.util.Calendar
(方便的方法 - 月份是基于 0 的,如 java.util.Calendar)
|
static java.util.Calendar |
getLocaleCalendar(int year, int month, int day, int hour, int minute, int second)
Convenience method - month is 0-based as in java.util.Calendar
(方便的方法 - 月份是基于 0 的,如 java.util.Calendar)
|
static java.util.Calendar |
getLocaleCalendar(java.util.TimeZone timeZone) |
static java.lang.String |
getLocaleFromLCID(int lcid)
Decode the language ID from LCID value
(从 LCID 值解码语言 ID)
|
static java.util.Locale |
getUserLocale() |
static java.util.TimeZone |
getUserTimeZone() |
static void |
resetUserLocale() |
static void |
resetUserTimeZone()
Clear the thread-local user time zone.
(清除线程本地用户时区。)
|
static void |
setUserLocale(java.util.Locale locale)
Sets default user locale.
(设置默认用户区域设置。)
|
static void |
setUserTimeZone(java.util.TimeZone timezone)
As time zone information is not stored in any format, it can be set before any date calculations take place.
(由于时区信息不以任何格式存储,因此可以在进行任何日期计算之前进行设置。)
|
public static final java.util.TimeZone TIMEZONE_UTC
public static final java.nio.charset.Charset CHARSET_1252
public static void setUserTimeZone(java.util.TimeZone timezone)
timezone
- the timezone under which date calculations take place
(timezone - 进行日期计算的时区)
public static java.util.TimeZone getUserTimeZone()
TimeZone.getDefault()
.
(用于日期计算的时区。如果未设置,则返回 TimeZone.getDefault()。)
public static void resetUserTimeZone()
public static void setUserLocale(java.util.Locale locale)
public static java.util.Locale getUserLocale()
Locale.getDefault()
.
(默认用户语言环境。如果未设置,则返回 Locale.getDefault()。)
public static void resetUserLocale()
public static java.util.Calendar getLocaleCalendar()
public static java.util.Calendar getLocaleCalendar(int year, int month, int day)
year
-
(年 -)
month
-
(月 -)
day
-
(日 -)
public static java.util.Calendar getLocaleCalendar(int year, int month, int day, int hour, int minute, int second)
year
-
(年 -)
month
-
(月 -)
day
-
(日 -)
hour
-
(小时 -)
minute
-
(分钟 -)
second
-
(第二 -)
public static java.util.Calendar getLocaleCalendar(java.util.TimeZone timeZone)
public static java.lang.String getLocaleFromLCID(int lcid)
lcid
- the LCID value
(lcid - LCID 值)
public static int getDefaultCodePageFromLCID(int lcid)
lcid
- the LCID value
(lcid - LCID 值)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.