public static int checkSmsVerifyCodeTime(Date currentTime,date sendTime){
int count=0;
try{
if(cuttentTime.before(sendTime) || cuttentTime.equls(sendTime) ){count=1;}//当前时间小于等于发送时间
if(cuttentTime.after(sendTime)){count=2};//当前时间大于发送时间
}catch(exception e){e.printStackTrace();}
System.out.println(count);
}
public static void main(String [] args) throws ParseException{
Date cuttentTime=new Date();
String time="2014-08-12 00:00:00";
Date datetime=(new SimpleDateFormat("yyyy-MM-dd").parse(time);
Calendar cal=Calendar.getInstance();
cal.setTime(dateTime);
cal.add(Calendar.SECOND,60);//添加60秒
System.out.println(cal.getTime);
int count=checkSmsVerifyCodeTime(cuttentTime,cal.getTime);
if(count>1){
System.out.println("ok");
}else{
System.out.println("fiail");
}
}
Map转换JSON:
Map<String,Object> resultMap=new HashMap<String,Object>();
1.JSONUtils.toJSON(resultMap);
Sysotem.out.println(JSONUtils.toJSON(resultMap));
2.这个使用。
private JSONObject result;
result=JSONObject.fromObject(reusltMap);
Sysotem.out.println(result);