-2

I get a compile error in the form:

incompatible types:java.util.date cannot to be converted to java.sql.Date
Date date=null;
date=new SimpleDateFormat("d MM y").parse((String)getSutunlar().get(index).getProduct_date());
VietHTran
  • 2,233
  • 2
  • 9
  • 16
Tahsin
  • 13
  • 1
  • 2
  • I recommend you don’t use `SimpleDateFormat` and `Date`. Those classes are poorly designed and long outdated, the former in particular notoriously troublesome. Instead use `LocalDate` and `DateTimeFormatter`, both from [java.time, the modern Java date and time API](https://docs.oracle.com/javase/tutorial/datetime/). – Ole V.V. Sep 16 '19 at 09:04

1 Answers1

1

That is because SimpleDateFormat returns java.util.date and you are trying to assign the result in the date variable of instance type java.sql.Date. You should have a look at the imports (at the top of your .java file), and try replacing java.sql.Date with java.util.date.

Safeer Ansari
  • 772
  • 4
  • 13