public static void main(String[] args) throws ParseException {

String firstDate = "2019-01-01"; 
String lastDate = "2019-012-31"; 
String createdTime = "2019-07-20";

SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); //创建日期转换对象:年 月 日
Long time = sdf.parse(createdTime).getTime();
Long time1 = sdf.parse(firstDate).getTime();
Long time2 = sdf.parse(lastDate).getTime();

if(time>=time1 && time<=time2){//转成long类型比较
System.out.println("在该时间段范围内");
}else{
System.out.println("不在该时间段范围内");
}

}

相关文章:

  • 2022-01-07
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2021-04-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案