The Artima Developer Community
Sponsored Link

Java Answers Forum
having problem with getting a date!!!

2 replies on 1 page. Most recent reply: Apr 14, 2002 11:30 AM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
patrick

Posts: 23
Nickname: patrick
Registered: Mar, 2002

having problem with getting a date!!! Posted: Apr 14, 2002 2:11 AM
Reply to this message Reply
Advertisement
hi,
i'm facing an error and i wonder if anyone may help me with it.
i'm trying to store a date in the date field in MySQL for the i'm using the
Date.getYear(),Date.getMonth()and Date.getDay concatenate them and insert but
i'm having an error like ambigous class Date
i tried the Calendar class but i'm having an error like can't make static
reference to methode get in Calendar.
can you please tell me how could i get a date format (yyyy-mm-dd) without
having errors?
thank you


Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: having problem with getting a date!!! Posted: Apr 14, 2002 2:19 AM
Reply to this message Reply
the error about ambiguity is because of the fact that there are two packages with a class called Date. Those two packages are java.sql and java.util. Probably, you are having an import statement which is importing * from these two packages, hence the error.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: having problem with getting a date!!! Posted: Apr 14, 2002 11:30 AM
Reply to this message Reply
And the way to solve it is to import java.util.Date, or java.sql.Date (whichever one you really want) explicitly. So you might end up with something like this:
import java.util.*;
import java.sql.*;
import java.util.Date;

Alternatively, you can fully qualify the name in your code, for example:
java.util.Date utilDate = new java.util.Date();
java.sql.Date sqlDate = new java.sql.Date(System.currentTimeMillis());

Of course, if you want to use both in the same module, you will need to fully specify at least one of them.

Now, you are well on your way to getting a date. Don't forget to bring flowers.

Flat View: This topic has 2 replies on 1 page
Topic: Program flow - throw/catch Previous Topic   Next Topic Topic: using jsp login page with ssl code sample

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use