Skip to content

Commit

Permalink
[persistence] Use ZonedDateTime instead of Date in ModifiablePersiste…
Browse files Browse the repository at this point in the history
…nceService interface (openhab#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:

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

Signed-off-by: Wouter Born <github@maindrain.net>
  • Loading branch information
wborn authored Jan 2, 2022
1 parent 33a553f commit 0bdaeef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
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;
Expand Down Expand Up @@ -507,7 +506,7 @@ private Response putItemState(@Nullable String serviceId, String itemName, Strin

ModifiablePersistenceService mService = (ModifiablePersistenceService) service;

mService.store(item, Date.from(dateTime.toInstant()), state);
mService.store(item, dateTime, state);
return Response.status(Status.OK).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 0bdaeef

Please sign in to comment.