Re: getHour() from database Datetime datatype
Posted By:
AlessandroA_Garbagnati
Posted On:
Thursday, April 12, 2001 02:42 PM
Hi,
Yes, since Java 1.1, some of the java.util.Date have been deprecated for a more powerful solution with the addition of java.util.Calendar and java.text.dateFormat. Please refer to the javadocs for more specific information.
To answer your question, one possible way to get the hour is:
Calendar cal = new GregorianCalendar();
cal.setTime(resultSet.getTimeStamp(""));
int hour = cal.get(Calendar.HOUR);
[or] int hour = cal.get(Calendar.HOUR_OF_DAY);