0

I have a field in sql table of type date with value 1944-01-02. Now I am writing a java function which will pull this data from the database and use it as a java method param. How should I handle it?

method looks like this:

void search(Date date);

I want to put 1944-01-02 in to the method param, but java complier complain does not matter if I import java.util.date or java.sql.date.

2 Answers2

0

You have to convert your sql date to java date:

java.util.Date utilDate = new java.util.Date(sqlDate.getTime());

Get more info about this at this Link

Community
  • 1
  • 1
Nero
  • 422
  • 8
  • 22
0

You might be looking for this:

search(Date.valueOf("1944-01-02"));

Format: yyyy-[m]m-[d]d

maraca
  • 8,468
  • 3
  • 23
  • 45