我有一个时间Timestamp
格式,是一个产品的过期时间,我必须检查这个产品是否过期。我能怎么做?
我尝试过这种方式,但实际上该函数总是返回 TRUE(我不知道为什么)
public boolean isAuctionExpired() {
// expiration_time is setted before, is the expiration date of a product!
Timestamp actualTimeStampDate = null;
try {
Date actual = new Date();
actualTimeStampDate = new Timestamp(actual.getTime());
} catch (Exception e) {
System.out.println("Exception :" + e);
}
boolean expired = (expiration_time.getTime() < actualTimeStampDate.getTime());
// Everything seems ok, except the boolean
System.out.println("product exp: "+expiration_time+", actual: "+actualTimeStampDate+" expired? "+expired);
return expired;
}
我想我犯了一个愚蠢的错误,但我看不到它!