Java订单过期时间校验
if (userOrder.getPayTime().compareTo(new Date()) < 0) {
log.info("订单已超时!");
throw new RestException(HttpStatus.ORDER_IS_TIMEOUT);
}
-----------------------扩展-------------------------------------------
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateNowStr = sdf.format(new Date());
String str = "2012-04-20 17:13:33";
Date now = sdf.parse(str);//使用parse()方法需要处理:ParseException异常
//或者方法上抛出:throws ParseException{}