java 得到小时,在java中获得下一个小时

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值