I have an hour, minute, date and millisecond timestamp, and am trying to create a Date object representing the time. The timestamp is provided in Eastern Daylight Time.
As mentioned by gtgaxiola: From the Calendar Documentation
Under the Field Manipulation section:
set(f, value) changes calendar field f to value. In addition, it sets an internal member variable to indicate that calendar field f has been changed. Although calendar field f is changed immediately, the calendar's time value in milliseconds is not recomputed until the next call to get(), getTime(), getTimeInMillis(), add(), or roll() is made.
The problem is that your getTime()
call recomputes the date but setTimeZone(..) doesn't set the internal member variable isTimeSet
to false. So the last line in your first output is wrong for you because you expect the timezone to be considered which is not.