In my project I need to to use current date and time. For this I'm importing java.util.Date.
This import is working fine few hours ago. But I have an error in R file ( r cannot resolve ) and this error is because of some xml mistake. When I resolved that issue and sync project again that error is gone. But after that I cannot able to import (java.util.Date , java.util.Calendar) in any of my project.
I tried to import this in my newly created project. But still not found java.util.Date.
Even in my old projects where this import is working fine few days ago. Currently it is not working and showing red.
import java.util.Calendar;
import java.util.Date;
Date and Calendar are showing in red.
Date d=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("hh:mm");
Above Date and SimpleDateFormat are showing in red.
And when I hover over there and press (control+alt) IDE will give option to import java.sql.Date not java.util.Date.
解决方案
I had this issue one time with java.util.calendar. Invalidating Cache/Restart worked for me.