2 **********************************************************************
\r
3 * Copyright (c) 2003-2008, International Business Machines
\r
4 * Corporation and others. All Rights Reserved.
\r
5 **********************************************************************
\r
7 * Created: October 2 2003
\r
9 **********************************************************************
\r
12 package com.ibm.icu.impl;
\r
13 import com.ibm.icu.util.TimeZone;
\r
14 import java.util.Date;
\r
17 * <code>TimeZoneAdapter</code> wraps a com.ibm.icu.util.TimeZone
\r
18 * subclass and inherits from java.util.TimeZone.
\r
19 * Without this class, we would need to 'port' java.util.Date to
\r
20 * com.ibm.icu.util as well, so that Date could interoperate properly
\r
21 * with the com.ibm.icu.util TimeZone and Calendar classes. With this
\r
22 * class, we can use java.util.Date together with com.ibm.icu.util
\r
25 * @see com.ibm.icu.util.TimeZone#setDefault
\r
29 public class TimeZoneAdapter extends java.util.TimeZone {
\r
31 // Generated by serialver from JDK 1.4.1_01
\r
32 static final long serialVersionUID = -2040072218820018557L;
\r
35 * The contained com.ibm.icu.util.TimeZone object. Must not be null.
\r
36 * We delegate all methods to this object.
\r
38 private TimeZone zone;
\r
41 * Given a java.util.TimeZone, wrap it in the appropriate adapter
\r
42 * subclass of com.ibm.icu.util.TimeZone and return the adapter.
\r
44 public static java.util.TimeZone wrap(com.ibm.icu.util.TimeZone tz) {
\r
45 return new TimeZoneAdapter(tz);
\r
49 * Return the java.util.TimeZone wrapped by this object.
\r
51 public com.ibm.icu.util.TimeZone unwrap() {
\r
56 * Constructs an adapter for a com.ibm.icu.util.TimeZone object.
\r
58 public TimeZoneAdapter(TimeZone zone) {
\r
60 super.setID(zone.getID());
\r
64 * TimeZone API; calls through to wrapped time zone.
\r
66 public void setID(String ID) {
\r
72 * TimeZone API; calls through to wrapped time zone.
\r
74 public boolean hasSameRules(java.util.TimeZone other) {
\r
75 return other instanceof TimeZoneAdapter &&
\r
76 zone.hasSameRules(((TimeZoneAdapter)other).zone);
\r
80 * TimeZone API; calls through to wrapped time zone.
\r
82 public int getOffset(int era, int year, int month, int day, int dayOfWeek,
\r
84 return zone.getOffset(era, year, month, day, dayOfWeek, millis);
\r
88 * TimeZone API; calls through to wrapped time zone.
\r
90 public int getRawOffset() {
\r
91 return zone.getRawOffset();
\r
95 * TimeZone API; calls through to wrapped time zone.
\r
97 public void setRawOffset(int offsetMillis) {
\r
98 zone.setRawOffset(offsetMillis);
\r
102 * TimeZone API; calls through to wrapped time zone.
\r
104 public boolean useDaylightTime() {
\r
105 return zone.useDaylightTime();
\r
109 * TimeZone API; calls through to wrapped time zone.
\r
111 public boolean inDaylightTime(Date date) {
\r
112 return zone.inDaylightTime(date);
\r
116 * Boilerplate API; calls through to wrapped object.
\r
118 public Object clone() {
\r
119 return new TimeZoneAdapter((TimeZone)zone.clone());
\r
123 * Boilerplate API; calls through to wrapped object.
\r
125 public synchronized int hashCode() {
\r
126 return zone.hashCode();
\r
130 * Boilerplate API; calls through to wrapped object.
\r
132 public boolean equals(Object obj) {
\r
133 if (obj instanceof TimeZoneAdapter) {
\r
134 obj = ((TimeZoneAdapter) obj).zone;
\r
136 return zone.equals(obj);
\r
140 * Returns a string representation of this object.
\r
141 * @return a string representation of this object.
\r
143 public String toString() {
\r
144 return "TimeZoneAdapter: " + zone.toString();
\r