0

I am attempting to create an app using android studio and when trying to run the app I seem to have an issue with one of the fields for my database.

 public void setTime(){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            this.time = Time.from(Instant.now());
        }
 }
     

I keep getting error: Cannot find setter for field. private Date time; If i remove the if statement about build version I get the same issue but android studio also underlines the this.time = Time.from(Instant.now()); statement and advises me to surround it with the if statement. How do I fix this?

  • if you want to have current date object then you can simply take it like ```new Date()``` instead of ```Time.from(Instant.now())``` FYI , regarding timezone of date object then you can refer this answer https://stackoverflow.com/a/308689/5696047 – jayesh gurudayalani Jan 31 '23 at 17:40

0 Answers0