• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.util.Date and java.sql.Date

 
Jil Van Wetter
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I've read some dates from an Excel file and stored them into an ArrayList of the Date type.
Now when I want to store the dates from the ArrayList into Mysql through java with
pstmt.setDate(2, dates.get(q));

I get the following error:
The method setDate(int, java.sql.Date) in the type PreparedStatement is not applicable for the arguments (int, java.util.Date)

How can I fix this or how can I change the java.util dates in the ArrayList to java.sql?

Thanks in advance!
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jil Van Wetter wrote:how can I change the java.util dates in the ArrayList to java.sql?

You can't change them but you can create java.sql.Date instances using the miilisecond value of a java.util.Date instance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic