jodatime jar比较时间

private boolean isIntervalLess2Minute(String createtime){
		DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
		DateTime datetime = DateTime.parse(createtime.substring(0, createtime.indexOf(".")), format); 
		DateTime currentTime = new DateTime();
		int diff = Minutes.minutesBetween(datetime, currentTime).getMinutes();
		if(diff>2){
			return false;
		}else{
			return true;
		}
	}


应用了jodatime第三方jar包,先要声明一个format,再用parse

你可能感兴趣的:(jodatime jar比较时间)