java 时间判断

import java.text.SimpleDateFormat;

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String nowTime = sdf.format(当前时间);

System.out.println(nowTime);

if(nowTime.compareTo(startTime)>=0 && nowTime.compareTo(endTime)<=0){
System.out.println("在范围");
}else
System.out.println("不在范围");

你可能感兴趣的:(java)