I want to convert an int value to a date.
For example, 20200605 is 2020-06-05
This is my code, Why doesn't it work?
public static void main(String[] args) {
int value = 19000101;
SimpleDateFormat originalFormat = new SimpleDateFormat("yyyyMMdd");
Date date = originalFormat.parse(Integer.toString(value));
SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
String formatedDate = newFormat.format(date);
}
I am getting an error on this line.
Date date = originalFormat.parse(Integer.toString(value));
The error message is
Type mismatch: cannot convert from java.util.Date to java.sql.Date
I don't know what it means.