You probably have some other "Date" class imported somewhere (or you have a Date class in you package, which does not need to be imported). With "import java.util.*" you are using the "other" Date. In this case it's best to explicitly specify java.util.Date in the code.

Or better, try to avoid naming your classes "Date".

Answer from sleske on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-util-package-java
Java.util Package in Java - GeeksforGeeks
November 8, 2025 - import java.util.*; public class GFG{ public static void main(String[] args){ // Using ArrayList List<String> names = new ArrayList<>(); names.add("Alice"); names.add("Bob"); names.add("Charlie"); // Using Collections utility class Collections.sort(names); System.out.println("Sorted Names: " + names); // Simulated user input String userName = "User"; System.out.println("Hello, " + userName + "!"); } }
๐ŸŒ
DataCamp
datacamp.com โ€บ doc โ€บ java โ€บ import
import Keyword in Java: Usage & Examples
Here, all classes from the java.util package are imported using the wildcard *. This allows the use of both ArrayList and HashMap without needing to specify their fully qualified names.
Discussions

What's the difference between import java.util.*; and import java.util.Date; ? - Stack Overflow
Specific import have precedence over wildcard imports. ... Should give you a compiler error stating that the reference to Date is ambiguous because both other.Date and java.util.Date matches. More on stackoverflow.com
๐ŸŒ stackoverflow.com
What does import java.util.* mean?
import all from java.util More on reddit.com
๐ŸŒ r/learnprogramming
7
2
June 20, 2018
Should I use import java.util.* for bringing in just one class? - Software Engineering Stack Exchange
when we import the Scanner class to a program which is the best and most suitable method from these two? import java.util.* import java.util.Scanner I'm a totally newbie to the programming and I ha... More on softwareengineering.stackexchange.com
๐ŸŒ softwareengineering.stackexchange.com
February 20, 2016
In Java, what does the import java.util.*; statement do? Question 1Answer a. Imports all classes from the java.util package. b. Imports only the java package. c. Imports all classes from the java package. d. Imports nothing.
Once imported, the class can be referenced directly without needing to use the fully qualified class name. The java.util.* statement imports all the classes and interfaces from the java.util package. More on studocu.com
๐ŸŒ studocu.com
1
July 1, 2024
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ java_packages.asp
Java Packages
In the previous example, we used ... random-number generator and other utility classes. To import a whole package, end the sentence with an asterisk sign (*)....
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ java.util package in java
java.util Package in Java - Scaler Topics
June 11, 2024 - To load the basic utility classes and interfaces provided by the java.util package, we need to use Java's import keyword. The import keyword is used to access and load the package and its respective classes into the Java program.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ how-to-import-package-in-java
How to Import Package in Java? - GeeksforGeeks
July 30, 2025 - Example: This imports all classes from the java.util package, such as ArrayList, HashMap, Date, etc.
Find elsewhere
๐ŸŒ
Coders Campus
coderscampus.com โ€บ home โ€บ java imports
Java Imports - How to Program with Java - Java Tutorial
May 5, 2021 - There is one other โ€œshortcutโ€ ... ALL of the classes that belong in the java.util package, you could just use the code import java.util.*. This will import everything in java.util, but it's important to note that it won't import ...
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ java-how-to-import-standard-java-utility-classes-419203
How to import standard Java utility classes | LabEx
LabEx provides interactive environments to help you master import concepts and package management. Utility classes in Java are collections of static methods that provide common, reusable functionality across different parts of an application.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ What-does-import-Java-util-in-Java-do
What does import Java.util.* in Java do?
July 30, 2019 - Java util package contains collection framework, collection classes, classes related to date and time, event model, internationalization, and miscellaneous utility classes. On importing this package, you can access all these classes and methods.
๐ŸŒ
Tcl Developer Site
tcl-lang.org โ€บ man โ€บ java1.2.6 โ€บ TclJava โ€บ JavaImportCmd.html
The java::import Command
# Import two classes from the java.util package java::import -package java.util Hashtable Vector # Call java methods using the shortened names set h [java::new Hashtable] set bool [java::instanceof $h Hashtable] set v [java::new Vector] set array [java::new {Hashtable[]} {10}] This example demonstrates how to use the optional -forget argument to remove a class from the import list.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ import-statement-in-java
Import Statement in Java - GeeksforGeeks
July 23, 2025 - Following are three ways to refer an external class or all external classes specified under a package: The import statement is optional, and we can use the fully-qualified name of the class to refer to a class or package in the program.
๐ŸŒ
Huda Tutorials
hudatutorials.com โ€บ java โ€บ util
java util Package - java.util Package in Java
June 4, 2024 - If you want to import all the classes from any Java package, your import statement must be like this import java.util.* that means you are importing entire java.util package.
๐ŸŒ
HappyCoders
happycoders.eu โ€บ home โ€บ java โ€บ java imports: classes, packages, and entire modules (jep 511)
Java Imports: Classes, Packages, and Entire Modules (JEP 511)
1 month ago - Java imports from class to module: packages, static imports, java.lang โ€“ and import module, which imports entire modules since Java 25.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ java โ€บ util โ€บ index.htm
Java.util Package Tutorial
Here we've used * operator to import all classes from java.util package and now any class can be used in the program.
๐ŸŒ
Studocu
studocu.com โ€บ university of the people โ€บ programming 2 โ€บ question
[Solved] In Java what does the import javautil statement do Question - Programming 2 (CS 1103) - Studocu
July 1, 2024 - Once imported, the class can be referenced directly without needing to use the fully qualified class name. The java.util.* statement imports all the classes and interfaces from the java.util package.
๐ŸŒ
Programiz
programiz.com โ€บ java-programming โ€บ packages-import
Java Packages and How to import them?
March 30, 2021 - The ArrayList class belongs to java.util package. To use it, we have to import the package first using the import statement.
๐ŸŒ
TheServerSide
theserverside.com โ€บ blog โ€บ Coffee-Talk-Java-News-Stories-and-Opinions โ€บ Java-Scanner-import
Java Scanner import
However, to use any classes in packages other than java.lang in your code, an import is required. The Scanner class is found in the java.util package, not java.lang.
Published: February 12, 2026