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.tr064.internal.soap;
15 import java.time.LocalDateTime;
16 import java.time.ZoneId;
17 import java.time.format.DateTimeFormatter;
18 import java.time.format.DateTimeParseException;
19 import java.util.Date;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.openhab.binding.tr064.internal.dto.additions.Call;
26 * The {@link CallListEntry} is used for post processing the retrieved call
29 * @author Jan N. Klug - Initial contribution
32 public class CallListEntry {
33 private static final DateTimeFormatter DATE_FORMAT_PARSER = DateTimeFormatter.ofPattern("dd.MM.yy HH:mm");
34 public @Nullable String localNumber;
35 public @Nullable String remoteNumber;
36 public @Nullable Date date;
37 public @Nullable Integer type;
38 public @Nullable Integer duration;
40 public CallListEntry(Call call) {
43 LocalDateTime.parse(call.getDate(), DATE_FORMAT_PARSER).atZone(ZoneId.systemDefault()).toInstant());
44 } catch (DateTimeParseException e) {
45 // ignore parsing error
48 String[] durationParts = call.getDuration().split(":");
49 duration = Integer.parseInt(durationParts[0]) * 60 + Integer.parseInt(durationParts[1]);
50 type = Integer.parseInt(call.getType());
51 if (CallListType.OUTBOUND_COUNT.typeString().equals(call.getType())) {
52 localNumber = call.getCallerNumber();
53 remoteNumber = call.getCalled();
55 localNumber = call.getCalledNumber();
56 remoteNumber = call.getCaller();