?
Solved

Java Dates

Posted on 2003-03-26
2
Medium Priority
?
242 Views
Last Modified: 2010-03-31
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
Comment
Question by:dds110
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 100 total points
ID: 8212899
 Change this:

Date date = new Date();

  to this:

java.util.Date date = new java.util.Date();
0
 
LVL 1

Expert Comment

by:Element115
ID: 8212906
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question