import java.util.Date; public class Example { public static void main(String[] args) { Date date = new Date(); int hashCode = date.hashCode(); System.out.println("Date hash code: " + hashCode); } }
import java.util.Date; import java.util.HashSet; public class Example { public static void main(String[] args) { HashSetOutput: Number of unique dates in set: 1 Package library: java.utildateSet = new HashSet<>(); dateSet.add(new Date()); dateSet.add(new Date()); System.out.println("Number of unique dates in set: " + dateSet.size()); } }