Package com.oorian.i18n
Class OorianLocale
java.lang.Object
com.oorian.i18n.OorianLocale
Thread-local holder for the current user's locale.
Provides a centralized, thread-safe way to store and retrieve the active Locale
for the current request. The locale is typically set early in the request lifecycle (e.g.,
from the HTTP Accept-Language header, session preferences, or user profile) and
used by Formatters for locale-aware formatting.
Usage:
// Set the locale for this request
OorianLocale.set(Locale.GERMANY);
// Retrieve the current locale
Locale locale = OorianLocale.get();
// Clear when the request is done
OorianLocale.clear();
If no locale has been set for the current thread, get() returns
Locale.getDefault().
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Method Summary
-
Method Details
-
set
Sets the locale for the current thread.- Parameters:
locale- the locale to set
-
get
Returns the locale for the current thread, orLocale.getDefault()if none is set.- Returns:
- the current locale, never
null
-
clear
public static void clear()Removes the locale from the current thread.Should be called at the end of a request to prevent memory leaks in thread-pool environments.
-