Example #1
0
        /*
         * Returns a new {@code SimpleTimeZone} with the same ID, {@code rawOffset} and daylight
         * savings time rules as this SimpleTimeZone.
         *
         * @return a shallow copy of this {@code SimpleTimeZone}.
         * @see java.lang.Cloneable
         */
        public override Object clone()
        {
            SimpleTimeZone zone = (SimpleTimeZone)base.MemberwiseClone();

            if (daylightSavings != null)
            {
                zone.daylightSavings = (GregorianCalendar)daylightSavings.clone();
            }
            return(zone);
        }
Example #2
0
        /*
         * Compares the specified object to this {@code SimpleTimeZone} and returns whether they
         * are equal. The object must be an instance of {@code SimpleTimeZone} and have the
         * same internal data.
         *
         * @param object
         *            the object to compare with this object.
         * @return {@code true} if the specified object is equal to this
         *         {@code SimpleTimeZone}, {@code false} otherwise.
         * @see #hashCode
         */
        public override bool Equals(Object obj)
        {
            if (!(obj is SimpleTimeZone))
            {
                return(false);
            }
            SimpleTimeZone tz = (SimpleTimeZone)obj;

            return(getID().equals(tz.getID()) &&
                   rawOffset == tz.rawOffset &&
                   useDaylight == tz.useDaylight &&
                   (!useDaylight || (startYear == tz.startYear &&
                                     startMonth == tz.startMonth &&
                                     startDay == tz.startDay && startMode == tz.startMode &&
                                     startDayOfWeek == tz.startDayOfWeek &&
                                     startTime == tz.startTime && endMonth == tz.endMonth &&
                                     endDay == tz.endDay &&
                                     endDayOfWeek == tz.endDayOfWeek &&
                                     endTime == tz.endTime && endMode == tz.endMode && dstSavings == tz.dstSavings)));
        }
Example #3
0
        public override bool hasSameRules(TimeZone zone)
        {
            if (!(zone is SimpleTimeZone))
            {
                return(false);
            }
            SimpleTimeZone tz = (SimpleTimeZone)zone;

            if (useDaylight != tz.useDaylight)
            {
                return(false);
            }
            if (!useDaylight)
            {
                return(rawOffset == tz.rawOffset);
            }
            return(rawOffset == tz.rawOffset && dstSavings == tz.dstSavings &&
                   startYear == tz.startYear && startMonth == tz.startMonth &&
                   startDay == tz.startDay && startMode == tz.startMode &&
                   startDayOfWeek == tz.startDayOfWeek &&
                   startTime == tz.startTime && endMonth == tz.endMonth &&
                   endDay == tz.endDay && endDayOfWeek == tz.endDayOfWeek &&
                   endTime == tz.endTime && endMode == tz.endMode);
        }