Package nl.talsmasoftware.context.locale
Maintain a current Locale context.
Setting a current locale can be done using the LocaleContextManager:
private static LocaleContextManager localeContextManager = new LocaleContextManager();
private void runWithLocale(Locale locale, Runnable someCode) {
try (Context<Locale> ctx = localeContextManager.initializeNewContext(locale)) {
someCode.run();
}
}
Obtaining the current locale works similar:
private void someCode() {
Locale currentLocale = LocaleContextManager.getCurrentLocaleOrDefault();
// ...
}
-
Class Summary Class Description LocaleContextManager Manager for aLocalebound to the current thread.