M_Gandhi M_Gandhi - 6 months ago 31
Java Question

get Timezone from Date object - Java

Can we get timezone details from java.util.Date object? I need to print the birthdate without affecting the timezone. Suppose someone has a birthdate on "12-15-1998 11:45:50 AM" with timezone America/Los_Angeles. Suppose I want to print birthdate in India. Then I don't want time zone in India change the birthdate to "12-16-1998 12:15:50 PM"? At the end, I just want to print "12-15-1998". thanks in advance.


A java.util.Date does not have a time zone associated with it. Its toString() method may make it appear to have a time zone, but it doesn't. The time zone provided by toString() is the system default time zone.

A Calendar does have a time zone associated with it. And that appears to be what you are trying to do.