Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

Java Dates

Here is my function:

import java.sql.*;
import java.util.*;
import java.text.*;

public class test
{
    public static void main(String[] args)
    {
        String s;
        Format fm;
        Date date = new Date();
        fm = new SimpleDateFormat("EEEE, MMMM dd, yyyy");
        s = fm.format(date);
        System.out.println(s);
    }
}

The error I get is on the line: Date date = new Date();
The error description is: reference to date is ambiguous, both class java.util.Date in java.util and class java.sql.Date in java.sql match

I need the util import for later.  Now what do I do(I've already created a different class as a workaround.  What do I do so I don't have to create the different class?)?

Thanks

DDS
0
dds110
Asked:
dds110
1 Solution
 
girionisCommented:
 Change this:

Date date = new Date();

  to this:

java.util.Date date = new java.util.Date();
0
 
Element115Commented:
import java.util.*;
import java.util.Date;
import java.sql.*;

Or

import java.sql.Date;

if you you want to use the sql date

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now