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.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
|
Modifier and Type | Method and Description |
---|---|
static int |
getDefaultCodePageFromLCID(int lcid)
Get default code page from LCID value
|
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
|
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
|
static java.util.Calendar |
getLocaleCalendar(java.util.TimeZone timeZone) |
static java.lang.String |
getLocaleFromLCID(int lcid)
Decode the language ID from LCID value
|
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 placepublic static java.util.TimeZone getUserTimeZone()
TimeZone.getDefault()
.public static void resetUserTimeZone()
public static void setUserLocale(java.util.Locale locale)
public static java.util.Locale getUserLocale()
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 valuepublic static int getDefaultCodePageFromLCID(int lcid)
lcid
- the LCID valueCopyright 2020 The Apache Software Foundation or its licensors, as applicable.