dtf.format(now) returns a string. not a date object.
if you just want to convert from LocalDate to Date, you could use this method:
LocalDateTime now = LocalDateTime.now();
Date yourDate = Date.from(datetime.atZone(ZoneId.systemDefault()).toInstant());
however if you still need to parse a string, you could inject a parser and assign a date object in your class.
for example:
public class Time {
Date time;
public Date getUpdateDt() {
return time;
}
public void setUpdateDt(Date time) {
this.time = time;
}
//this method will accept a string and inject a date format parser
public void setUpdateDt(String timeStr,DateTimeFormatter dtf) {
LocalDateTime datetime =LocalDateTime.parse(timeStr, dtf);
this.time = Date.from(datetime.atZone(ZoneId.systemDefault()).toInstant());
}
public static void main(String args[]) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
Time time = new Time();
time.setUpdateDt(dtf.format(now),dtf);
System.out.println(time.getUpdateDt());
}