[persistence] Use ZonedDateTime instead of Date in ModifiablePersistenceService interface (#2660)

If PRs are created to implement this interface, it would be better if we can prevent the propagation of old APIs like Date.

Related to:

* https://github.com/openhab/openhab-addons/pull/11922
* https://github.com/openhab/openhab-addons/pull/11923
* https://github.com/openhab/openhab-core/issues/2618#issuecomment-1003544762

Signed-off-by: Wouter Born <github@maindrain.net>
pull/2661/head
Wouter Born 2022-01-02 20:45:10 +01:00 committed by GitHub
parent 33a553fa4d
commit 0bdaeef789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -15,7 +15,6 @@ package org.openhab.core.io.rest.core.internal.persistence;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@ -507,7 +506,7 @@ public class PersistenceResource implements RESTResource {
ModifiablePersistenceService mService = (ModifiablePersistenceService) service;
mService.store(item, Date.from(dateTime.toInstant()), state);
mService.store(item, dateTime, state);
return Response.status(Status.OK).build();
}
}

View File

@ -12,7 +12,7 @@
*/
package org.openhab.core.persistence;
import java.util.Date;
import java.time.ZonedDateTime;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.items.Item;
@ -44,7 +44,7 @@ public interface ModifiablePersistenceService extends QueryablePersistenceServic
* @param date the date of the record
* @param state the state to be recorded
*/
void store(Item item, Date date, State state);
void store(Item item, ZonedDateTime date, State state);
/**
* Removes data associated with an item from a persistence service.