2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.persistence.mongodb.internal;
15 import java.text.DateFormat;
16 import java.time.ZonedDateTime;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.core.persistence.HistoricItem;
20 import org.openhab.core.types.State;
23 * This is the implementation of the MongoDB historic item.
25 * @author Thorsten Hoeger - Initial contribution
28 public class MongoDBItem implements HistoricItem {
30 private final String name;
31 private final State state;
32 private final ZonedDateTime timestamp;
34 public MongoDBItem(String name, State state, ZonedDateTime timestamp) {
37 this.timestamp = timestamp;
41 public String getName() {
46 public State getState() {
51 public ZonedDateTime getTimestamp() {
56 public String toString() {
57 return DateFormat.getDateTimeInstance().format(timestamp) + ": " + name + " -> " + state.toString();