Re: Does ID describe a TimeZone completely?
On 1/27/2011 6:05 AM, Robin Wenger wrote:
Lets start with two TimeZone declarations
TimeZone a;
TimeZone b;
When I code now:
....fill a (externally)......
TimeZone b.setID(a.getID());
Are then both TimeZone objects equal (in content, not in memory) ?
It depends on what class(es) they are. Keep in mind that TimeZone
itself is an abstract class, so there cannot be any such thing as a
"purely TimeZone" object instance: Any TimeZone object is actually an
object of some TimeZone subclass (like SimpleTimeZone). It is up to
that subclass' own equals() method to decide what "equality" is.
In other words: Does an ID describe completely a TimeZone or are there other fields (Which ?) hidden in a TimeZone object
which need to be copied as well?
As above, it depends on the concrete subclass. SimpleTimeZone
quite definitely holds other values; it's not clear from the Javadoc
which of them participate in equals().
If you want to copy TimeZone objects (why?), you could try clone().
By the way: How do I set a TimeZone object to the current, local TimeZone?
TimeZone.getDefault().
Can I assign it somehow from a Date() object?
Date has a getTimezoneOffset() method, but it's deprecated (like
almost everything else in Date).
--
Eric Sosman
esosman@ieee-dot-org.invalid