1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.timezone; 18 19 import android.annotation.NonNull; 20 21 import com.android.internal.annotations.GuardedBy; 22 23 import java.util.Objects; 24 25 /** 26 * Android's internal factory for java.util.TimeZone objects. Provides access to core library time 27 * zone metadata not available via {@link java.util.TimeZone}. 28 * 29 * @hide 30 */ 31 public final class ZoneInfoDb { 32 33 private static final Object sLock = new Object(); 34 @GuardedBy("sLock") 35 private static ZoneInfoDb sInstance; 36 37 /** 38 * Obtains the singleton instance. 39 */ 40 @NonNull getInstance()41 public static ZoneInfoDb getInstance() { 42 synchronized (sLock) { 43 if (sInstance == null) { 44 sInstance = new ZoneInfoDb(com.android.i18n.timezone.ZoneInfoDb.getInstance()); 45 } 46 } 47 return sInstance; 48 } 49 50 @NonNull 51 private final com.android.i18n.timezone.ZoneInfoDb mDelegate; 52 ZoneInfoDb(com.android.i18n.timezone.ZoneInfoDb delegate)53 private ZoneInfoDb(com.android.i18n.timezone.ZoneInfoDb delegate) { 54 mDelegate = Objects.requireNonNull(delegate); 55 } 56 57 /** 58 * Returns the tzdb version in use. 59 */ 60 @NonNull getVersion()61 public String getVersion() { 62 return mDelegate.getVersion(); 63 } 64 } 65