2 * Copyright (c) 2010-2021 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;
19 * The {@link ErrorLine} is responsible for holding information about a single error line.
21 * @author Boris Krivonog - Initial contribution
23 public class ErrorLine {
24 private final byte error;
25 private final String timestamp;
27 public ErrorLine(byte error, String timestamp) {
29 this.timestamp = timestamp;
33 public String toString() {
34 return String.format("%d @ %s", error, timestamp);
41 public String timestampAsString() {
45 public ZonedDateTime timestamp() {
46 int year = Integer.parseInt(timestamp.substring(0, 2)) + 1000;
50 int month = Integer.parseInt(timestamp.substring(2, 4));
51 int day = Integer.parseInt(timestamp.substring(4, 6));
52 int hour = Integer.parseInt(timestamp.substring(7, 9));
53 int min = Integer.parseInt(timestamp.substring(10, 12));
54 int sec = Integer.parseInt(timestamp.substring(13, 15));
56 return ZonedDateTime.of(year, month, day, hour, min, sec, 0, ZoneId.systemDefault());