Please provide the code getting next hour from database. For example I am getting a timestamp from the database as:
String sqlupdate = "select UploadedDate from CAF_Entry where Status='new' and Reference=0 order by UploadedDate limit 1";
System.out.println("sql query"+sqlupdate);
Statement stupdate = con.createStatement();
ResultSet rsupdate = stupdate.executeQuery(sqlupdate);
if(rsupdate.next())
{
date22=rsupdate.getTimestamp("UploadedDate");
String stringdate=date22.toString();`
I am getting the date 2012-11-12 10:30:00
How do I get the next hour, such as 2012-11-12 11:00:00?
解决方案
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(date22.getTime);
calendar.add(Calendar.HOUR, 1);
After that you can use SimpleDateFormat to format the date to a String if you want it in that form. Calendar.getTime() will return a java.util.Date object if you need one.