JadiraOrg / jadira

Jadira Framework
Apache License 2.0
74 stars 44 forks source link

Cannot resolve method 'withZone' in 'OffsetDateTime' #122

Open rcbandit111 opened 1 year ago

rcbandit111 commented 1 year ago

I have the following code that I want to migrate:

Gradle dependency:

implementation 'org.jadira.usertype:usertype.core:7.0.0.CR1'

Entity:

    import org.joda.time.DateTime;

    @Entity
    @Table(name = "logs")
    public class Log {

      @Column(name = "inserted_date")
      @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
      private DateTime insertedDate;
    }

.....

DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("yy-mm-dd'T'HH:mm:ss'Z'");

log.setInsertedDate(DateTime.now());
dateFormatter.print(log.getInsertedDate().withZone(DateTimeZone.UTC)));

I updated the code to this:

Entity:

    import java.time.OffsetDateTime;

    @Entity
    @Table(name = "logs")
    public class Log {

      @Column(name = "inserted_date")
      private OffsetDateTime insertedDate;
    }

.....

DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("yy-mm-dd'T'HH:mm:ss'Z'");

log.setInsertedDate(OffsetDateTime.now());
dateFormatter.print(log.getInsertedDate().withZone(DateTimeZone.UTC)));

But I get error Cannot resolve method 'withZone' in 'OffsetDateTime'. Do you know what is the proper way to update method withZone?