SimpleDateFormat 出现错误 Call requires API level 24 (current min is 15)

这个故事是这样的

今天写打卡时间的时候需要获取一下当前时间,然后我就写了一个这个

[java] view plain copy
 
  1. SimpleDateFormat sDF =   new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");  
  2. tring date = sDF.format(Date());  


然后alter+enter包导入

然后就出了一个这个

Call requires API level 24 (current min is 15): android.icu.text.SimpleDateFormat#SimpleDaormat

我开始以为是版本的问题,然后我就去下了一个新的SDK回来,折腾了三个小时发现无卵用

后来仔细看错误提示发现是包导入的问题……

应该导入

[java] view plain copy
 
  1. import java.text.SimpleDateFormat;  
  2. import java.util.Date;  

然后我智障自动导入了这个

[java] view plain copy
 
  1. import android.icu.text.SimpleDateFormat;  
原文地址:https://www.cnblogs.com/cappuccino/p/7596711.html