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
I don't understand what does java.util. mean - Stack Overflow
What does java.util.*; do? Why do we include it at the beginning of our files? ... It's one of the many imports that come with the Java language. This question however is not appropriate for SO. More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
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.
๐ŸŒ
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.
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.
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
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.
Top answer
1 of 2
4

The statement java.util.*; imports all of the java.util package members so that you don't have to use a package member's fully qualified name. According to the JavaDocs here the package java.util

Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array)

Although this approach can seem more convenient and is sometimes appropriate you shouldn't always be including an import java.util.*; statement at the beginning of all of your files unless you are using a substantial amount of the members contained in the java.util package. Only include the members that you use like so:

import java.util.ArrayList;
import java.util.LinkedList;

By doing so it helps make you more familiar with each package member that you're using instead of blindly importing the whole package. The most important reason is that by using the wildcard character(*) you have a greater chance of coming across name ambiguities which can lead to errors.

import java.awt.*;
import java.util.*;

In the above code example, the class List becomes ambiguous because both packages have a List class.

2 of 2
-3

Think of it like a library of methods that you now have access to. You are basically importing more functionality into your project

When you do

import java.util.*

you now have the ability to do things like create arrays, manipulate dates and so on... (https://docs.oracle.com/javase/7/docs/api/java/util/package-summary.html)

The .* means you are importing all of the util functions like java.util.Arrays or java.util.Date...

๐ŸŒ
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.