javaandroidandroid-studiojava.util.datedate

Stop Android Studio from auto-importing java.sql.Date


How can I set up that Android Studio always imports java.util.Date? It ALWAYS auto-imports java.sql.Date, which I never use, which then always gives me errors later if I don’t explicitly check the import statements (which of course nobody ever does). It happens each and every time I do something like

Date d = new Date();

Which is a valid constructor for both. Is there some kind of import priority?


Solution

  • I had the same problem and turned out java.util.Date was in "Exclude from Import" list in Settings (Settings- Auto Import - Exclude from Import). Clear this list and IDE will be asking which lib to import. Clear the list, add a java.SQL.Date and IDE will be importing java.util.Date asking nothing.