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.binding.regoheatpump.internal.rego6xx;
15 import java.time.ZoneId;
16 import java.time.ZonedDateTime;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
21 * The {@link ErrorLine} is responsible for holding information about a single error line.
23 * @author Boris Krivonog - Initial contribution
26 public class ErrorLine {
27 private final byte error;
28 private final String timestamp;
30 public static final ErrorLine NO_ERROR = new ErrorLine((byte) 0, "");
32 public ErrorLine(byte error, String timestamp) {
34 this.timestamp = timestamp;
38 public String toString() {
39 return String.format("%d @ %s", error, timestamp);
46 public String timestampAsString() {
50 public ZonedDateTime timestamp() {
51 int year = Integer.parseInt(timestamp.substring(0, 2)) + 1000;
55 int month = Integer.parseInt(timestamp.substring(2, 4));
56 int day = Integer.parseInt(timestamp.substring(4, 6));
57 int hour = Integer.parseInt(timestamp.substring(7, 9));
58 int min = Integer.parseInt(timestamp.substring(10, 12));
59 int sec = Integer.parseInt(timestamp.substring(13, 15));
61 return ZonedDateTime.of(year, month, day, hour, min, sec, 0, ZoneId.systemDefault());