本文整理了Java中org.threeten.bp.zone.ZoneRulesInitializer
类的一些代码示例,展示了ZoneRulesInitializer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneRulesInitializer
类的具体详情如下:
包路径:org.threeten.bp.zone.ZoneRulesInitializer
类名称:ZoneRulesInitializer
[英]Controls how the time-zone rules are initialized.
The default behavior is to use ServiceLoader to find instances of ZoneRulesProvider. Use the #setInitializer(ZoneRulesInitializer) method to replace this behavior. The initializer instance must perform the work of creating the ZoneRulesProvider within the #initializeProviders() method to ensure that the provider is not initialized too early.
The initializer must be set before class loading of any other ThreeTen-Backport class to have any effect!
This class has been added primarily for the benefit of Android.
[中]控制时区规则的初始化方式。
默认行为是使用ServiceLoader查找ZoneRulesProvider的实例。使用#setInitializer(ZoneRulesInitializer)方法替换此行为。initializer实例必须在#initializeProviders()方法中执行创建ZoneRulesProvider的工作,以确保不会过早初始化提供程序。
初始化器必须在加载任何其他Three-Ten Backport类之前设置才能生效!
添加这个类主要是为了Android的好处。
代码示例来源:origin: JakeWharton/ThreeTenABP
public static void init(Context context) {
if (!initialized.getAndSet(true)) {
ZoneRulesInitializer.setInitializer(new AssetsZoneRulesInitializer(context));
}
}
代码示例来源:origin: ThreeTen/threetenbp
static void initialize() {
if (INITIALIZED.getAndSet(true)) {
throw new IllegalStateException("Already initialized");
}
// Set the default initializer if none has been provided yet.
INITIALIZER.compareAndSet(null, new ServiceLoaderZoneRulesInitializer());
INITIALIZER.get().initializeProviders();
}
代码示例来源:origin: org.threeten/threetenbp
static void initialize() {
if (INITIALIZED.getAndSet(true)) {
throw new IllegalStateException("Already initialized");
}
// Set the default initializer if none has been provided yet.
INITIALIZER.compareAndSet(null, new ServiceLoaderZoneRulesInitializer());
INITIALIZER.get().initializeProviders();
}
代码示例来源:origin: gabrielittner/lazythreetenbp
/**
* Initialize threetenbp to use LazyThreeTenBp's ZoneRulesProvider
*/
@MainThread
public static void init(Context context) {
if (INITIALIZED.getAndSet(true)) {
return;
}
ZoneRulesInitializer.setInitializer(
new LazyZoneRulesInitializer((Application) context.getApplicationContext()));
}
内容来源于网络,如有侵权,请联系作者删除!