1/* 2 ******************************************************************************* 3 * Copyright (C) 2008, International Business Machines Corporation and * 4 * others. All Rights Reserved. * 5 ******************************************************************************* 6 */ 7package com.ibm.icu.impl.jdkadapter; 8 9import java.util.Date; 10import java.util.Locale; 11 12import com.ibm.icu.impl.icuadapter.TimeZoneJDK; 13import com.ibm.icu.util.TimeZone; 14 15/** 16 * TimeZoneICU is an adapter class which wraps ICU4J TimeZone and 17 * implements java.util.TimeZone APIs. 18 */ 19public class TimeZoneICU extends java.util.TimeZone { 20 21 private static final long serialVersionUID = 6019030618408620277L; 22 23 private TimeZone fIcuTz; 24 25 private TimeZoneICU(TimeZone icuTz) { 26 fIcuTz = icuTz; 27 } 28 29 public static java.util.TimeZone wrap(TimeZone icuTz) { 30 if (icuTz instanceof TimeZoneJDK) { 31 return ((TimeZoneJDK)icuTz).unwrap(); 32 } 33 return new TimeZoneICU(icuTz); 34 } 35 36 public TimeZone unwrap() { 37 return fIcuTz; 38 } 39 40 @Override 41 public Object clone() { 42 TimeZoneICU other = (TimeZoneICU)super.clone(); 43 other.fIcuTz = (TimeZone)fIcuTz.clone(); 44 return other; 45 } 46 47 //public String getDisplayName() 48 //public String getDisplayName(boolean daylight, int style) 49 //public String getDisplayName(Locale locale) 50 51 @Override 52 public String getDisplayName(boolean daylight, int style, Locale locale) { 53 return fIcuTz.getDisplayName(daylight, style, locale); 54 } 55 56 @Override 57 public int getDSTSavings() { 58 return fIcuTz.getDSTSavings(); 59 } 60 61 @Override 62 public String getID() { 63 return fIcuTz.getID(); 64 } 65 66 @Override 67 public int getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds) { 68 return fIcuTz.getOffset(era, year, month, day, dayOfWeek, milliseconds); 69 } 70 71 @Override 72 public int getOffset(long date) { 73 return fIcuTz.getOffset(date); 74 } 75 76 @Override 77 public int getRawOffset() { 78 return fIcuTz.getRawOffset(); 79 } 80 81 @Override 82 public boolean hasSameRules(java.util.TimeZone other) { 83 return other.hasSameRules(TimeZoneICU.wrap(fIcuTz)); 84 } 85 86 @Override 87 public boolean inDaylightTime(Date date) { 88 return fIcuTz.inDaylightTime(date); 89 } 90 91 @Override 92 public void setID(String ID) { 93 fIcuTz.setID(ID); 94 } 95 96 @Override 97 public void setRawOffset(int offsetMillis) { 98 fIcuTz.setRawOffset(offsetMillis); 99 } 100 101 @Override 102 public boolean useDaylightTime() { 103 return fIcuTz.useDaylightTime(); 104 } 105} 106