数据库取出来的Timestamp和获取系统当前时间转成Timestamp类型比较大小,如补充: 10
SimpleDateFormatsdf=newSimpleDateFormat("yyyy-MM-ddhh:mm:ss");Timestamptp=newTimestam...
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Timestamp tp=new Timestamp(System.currentTimeMillis());
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(tp);
String tp2=sdf.format(rightNow.getTime()) ;
Timestamp reStr = null;
try {
reStr = new Timestamp(sdf.parse(tp2).getTime());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Timestamp shixiaodate=personInfoPromotions.get(0).getTopExpirationDate();
if(shixiaodate>reStr){//这句报错
} 展开
Timestamp tp=new Timestamp(System.currentTimeMillis());
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(tp);
String tp2=sdf.format(rightNow.getTime()) ;
Timestamp reStr = null;
try {
reStr = new Timestamp(sdf.parse(tp2).getTime());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Timestamp shixiaodate=personInfoPromotions.get(0).getTopExpirationDate();
if(shixiaodate>reStr){//这句报错
} 展开
1个回答
展开全部
改陵罩档闷老成
shixiaodate.compareTo(reStr) > 0
或者用 Timestamp 特有的 after/before 方法尺乱
参考
http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/Timestamp.html#after%28java.sql.Timestamp%29
shixiaodate.compareTo(reStr) > 0
或者用 Timestamp 特有的 after/before 方法尺乱
参考
http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/Timestamp.html#after%28java.sql.Timestamp%29
来自:求助得到的回答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询