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.sensorcommunity.internal.util;
15 import static org.junit.jupiter.api.Assertions.*;
17 import java.time.LocalDateTime;
18 import java.time.format.DateTimeParseException;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.Test;
22 import org.openhab.binding.sensorcommunity.internal.utils.DateTimeUtils;
25 * The {@link DateTimeTest} Test DateTimeFormatter provided in utils package
27 * @author Bernd Weymann - Initial contribution
30 public class DateTimeTest {
33 public void testJSonTime() {
34 String jsonDateString = "2020-08-14 14:53:21";
36 LocalDateTime dt = LocalDateTime.from(DateTimeUtils.DTF.parse(jsonDateString));
37 assertEquals(14, dt.getDayOfMonth(), "Day");
38 assertEquals(8, dt.getMonthValue(), "Month");
39 assertEquals(2020, dt.getYear(), "Year");
41 String s = dt.format(DateTimeUtils.DTF);
42 assertEquals(jsonDateString, s, "String");
43 } catch (DateTimeParseException e) {