• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GENERATED SOURCE. DO NOT MODIFY. */
2 // © 2016 and later: Unicode, Inc. and others.
3 // License & terms of use: http://www.unicode.org/copyright.html#License
4 /*
5  **********************************************************************
6  * Copyright (c) 2003-2010, International Business Machines
7  * Corporation and others.  All Rights Reserved.
8  **********************************************************************
9  * Author: Alan Liu
10  * Created: October 2 2003
11  * Since: ICU 2.8
12  **********************************************************************
13  */
14 
15 package ohos.global.icu.impl;
16 import java.util.Date;
17 
18 import ohos.global.icu.util.TimeZone;
19 
20 /**
21  * <code>TimeZoneAdapter</code> wraps a ohos.global.icu.util.TimeZone
22  * subclass and inherits from java.util.TimeZone.
23  * Without this class, we would need to 'port' java.util.Date to
24  * ohos.global.icu.util as well, so that Date could interoperate properly
25  * with the ohos.global.icu.util TimeZone and Calendar classes.  With this
26  * class, we can use java.util.Date together with ohos.global.icu.util
27  * classes.
28  *
29  * @see ohos.global.icu.util.TimeZone#setDefault
30  * @author Alan Liu
31  * @hide exposed on OHOS
32  */
33 public class TimeZoneAdapter extends java.util.TimeZone {
34 
35     // Generated by serialver from JDK 1.4.1_01
36     static final long serialVersionUID = -2040072218820018557L;
37 
38     /**
39      * The contained ohos.global.icu.util.TimeZone object.  Must not be null.
40      * We delegate all methods to this object.
41      */
42     private TimeZone zone;
43 
44     /**
45      * Given a java.util.TimeZone, wrap it in the appropriate adapter
46      * subclass of ohos.global.icu.util.TimeZone and return the adapter.
47      */
wrap(ohos.global.icu.util.TimeZone tz)48     public static java.util.TimeZone wrap(ohos.global.icu.util.TimeZone tz) {
49         return new TimeZoneAdapter(tz);
50     }
51 
52     /**
53      * Return the java.util.TimeZone wrapped by this object.
54      */
unwrap()55     public ohos.global.icu.util.TimeZone unwrap() {
56         return zone;
57     }
58 
59     /**
60      * Constructs an adapter for a ohos.global.icu.util.TimeZone object.
61      */
TimeZoneAdapter(TimeZone zone)62     public TimeZoneAdapter(TimeZone zone) {
63         this.zone = zone;
64         super.setID(zone.getID());
65     }
66 
67     /**
68      * TimeZone API; calls through to wrapped time zone.
69      */
70     @Override
setID(String ID)71     public void setID(String ID) {
72         super.setID(ID);
73         zone.setID(ID);
74     }
75 
76     /**
77      * TimeZone API; calls through to wrapped time zone.
78      */
79     @Override
hasSameRules(java.util.TimeZone other)80     public boolean hasSameRules(java.util.TimeZone other) {
81         return other instanceof TimeZoneAdapter &&
82             zone.hasSameRules(((TimeZoneAdapter)other).zone);
83     }
84 
85     /**
86      * TimeZone API; calls through to wrapped time zone.
87      */
88     @Override
getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)89     public int getOffset(int era, int year, int month, int day, int dayOfWeek,
90                          int millis) {
91         return zone.getOffset(era, year, month, day, dayOfWeek, millis);
92     }
93 
94     /**
95      * TimeZone API; calls through to wrapped time zone.
96      */
97     @Override
getRawOffset()98     public int getRawOffset() {
99         return zone.getRawOffset();
100     }
101 
102     /**
103      * TimeZone API; calls through to wrapped time zone.
104      */
105     @Override
setRawOffset(int offsetMillis)106     public void setRawOffset(int offsetMillis) {
107         zone.setRawOffset(offsetMillis);
108     }
109 
110     /**
111      * TimeZone API; calls through to wrapped time zone.
112      */
113     @Override
useDaylightTime()114     public boolean useDaylightTime() {
115         return zone.useDaylightTime();
116     }
117 
118     /**
119      * TimeZone API; calls through to wrapped time zone.
120      */
121     @Override
inDaylightTime(Date date)122     public boolean inDaylightTime(Date date) {
123         return zone.inDaylightTime(date);
124     }
125 
126     /**
127      * Boilerplate API; calls through to wrapped object.
128      */
129     @Override
clone()130     public Object clone() {
131         return new TimeZoneAdapter((TimeZone)zone.clone());
132     }
133 
134     /**
135      * Boilerplate API; calls through to wrapped object.
136      */
137     @Override
hashCode()138     public synchronized int hashCode() {
139         return zone.hashCode();
140     }
141 
142     /**
143      * Boilerplate API; calls through to wrapped object.
144      */
145     @Override
equals(Object obj)146     public boolean equals(Object obj) {
147         if (this == obj) {
148             return true;
149         }
150         if (obj instanceof TimeZoneAdapter) {
151             TimeZone anotherZone = ((TimeZoneAdapter) obj).zone;
152             return zone.equals(anotherZone);
153         }
154         return false;
155     }
156 
157     /**
158      * Returns a string representation of this object.
159      * @return  a string representation of this object.
160      */
161     @Override
toString()162     public String toString() {
163         return "TimeZoneAdapter: " + zone.toString();
164     }
165 }
166