I have two Date objects. One holds just the date, and one holds just the time. You would THINK that adding the getTime of both of them would give you the date and time but it doesn't give you what you think!
Try this sample program:
You would think that you would get today's date with 1630 (4:30 pm) as the time...but you get 22:30. I think this has something to do with GMT, but given that none of the Date or Calendar objects show that (when you print them out they show you CST or CDT where I am).
Why does it add four hours like that?
Also, what is the most efficient way to get it corrected (to show 1630 instead of 2230)? Would it be just to add what I get from GregorianCalendar.get(Calendar.ZONE_OFFSET) to the date?
GregorianCalendar cal2 = new GregorianCalendar(); int offset = cal.get(Calendar.ZONE_OFFSET); cal2.setTimeInMillis(date.getTime() + time.getTime() + offset);
Thanks! [ October 05, 2006: Message edited by: Darrin Smith ]