]> git.basschouten.com Git - openhab-addons.git/blob
b54490968c781a9592b4f39a692cd08b12096e82
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.airquality.internal.json;
14
15 import java.time.ZonedDateTime;
16 import java.time.format.DateTimeParseException;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19
20 import com.google.gson.annotations.SerializedName;
21
22 /**
23  * The {@link AirQualityJsonTime} is responsible for storing
24  * the "time" node from the waqi.org JSON response
25  *
26  * @author Kuba Wolanin - Initial contribution
27  * @author GaĆ«l L'hopital - Use ZonedDateTime instead of Calendar
28  */
29 @NonNullByDefault
30 public class AirQualityJsonTime {
31
32     @SerializedName("s")
33     private String dateString = "";
34
35     @SerializedName("tz")
36     private String timeZone = "";
37
38     private String iso = "";
39
40     /**
41      * Get observation time
42      *
43      * @return {ZonedDateTime}
44      */
45     public ZonedDateTime getObservationTime() throws DateTimeParseException {
46         return ZonedDateTime.parse(iso);
47     }
48 }