| Author |
Calendar
|
Zsuzsa Pocsai
Greenhorn
Joined: Nov 18, 2002
Posts: 11
|
|
I need help please, I have got an object which has a creation date time parameter which is of type calendar. When I save the object to the database it is 14pm 34 sec. When I read it back it is always one hour behind I have no idea why. I have managed to locate that it goes wrong when I put the Date opject into the Calendars consturctor. The code is the following. Can anyone please tell me what is wrong with it? Thank you private void getDateTime(String columnName, ResultSet rs, Calendar calendar) throws IntException { java.sql.Date date; java.sql.Time time; java.sql.Date datetime; long longTime; try { date = rs.getDate(columnName); time = rs.getTime(columnName); System.out.println(time.getHours()); System.out.println(time.getMinutes()); if (date != null) { longTime = date.getTime(); if (time != null) longTime += time.getTime(); longTime = date.getTime() + time.getTime(); System.out.println(time.getTime()); datetime = new java.sql.Date(longTime); int offset = datetime.getTimezoneOffset(); //System.out.println(datetime.getHours()); //System.out.println(datetime.getMinutes()); calendar.setTime(datetime); } else { // Zero the date setZeroDate(calendar); } } catch (SQLException sqle) { "Error obtaining Oracle Date and Time. " + sqle.toString(); }
|
 |
David Mason
Ranch Hand
Joined: Jan 21, 2002
Posts: 58
|
|
Is this a Daylight Saving Time effect ? You say that it goes wrong when you instantiate the calendar. Is Calendar converting the absolute time that is held in the Date object into the time in your current time zone, including your current Daylight savings settings? Are you using the locale version of the constructor ? Have you reverted to UCT settings and tried again? Hope this helps DBM
|
 |
 |
|
|
subject: Calendar
|
|
|