]> git.basschouten.com Git - openhab-addons.git/blob
5c5ee74e1c9a07d7e0c9fd778b0be42a7a3a81a6
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.ihc.internal.ws.datatypes;
14
15 import java.time.LocalDateTime;
16 import java.time.ZoneId;
17 import java.time.ZonedDateTime;
18
19 /**
20  * Class for WSDate complex type.
21  *
22  * @author Pauli Anttila - Initial contribution
23  */
24 public class WSDate {
25     private int hours;
26     private int minutes;
27     private int seconds;
28     private int year;
29     private int day;
30     private int monthWithJanuaryAsOne;
31
32     public WSDate() {
33     }
34
35     public WSDate(int hours, int minutes, int seconds, int year, int day, int monthWithJanuaryAsOne) {
36         this.hours = hours;
37         this.minutes = minutes;
38         this.seconds = seconds;
39         this.year = year;
40         this.day = day;
41         this.monthWithJanuaryAsOne = monthWithJanuaryAsOne;
42     }
43
44     /**
45      * Gets the hours value for this WSDate.
46      *
47      * @return hours
48      */
49     public int getHours() {
50         return hours;
51     }
52
53     /**
54      * Sets the hours value for this WSDate.
55      *
56      * @param hours
57      */
58     public void setHours(int hours) {
59         this.hours = hours;
60     }
61
62     /**
63      * Gets the minutes value for this WSDate.
64      *
65      * @return minutes
66      */
67     public int getMinutes() {
68         return minutes;
69     }
70
71     /**
72      * Sets the minutes value for this WSDate.
73      *
74      * @param minutes
75      */
76     public void setMinutes(int minutes) {
77         this.minutes = minutes;
78     }
79
80     /**
81      * Gets the seconds value for this WSDate.
82      *
83      * @return seconds
84      */
85     public int getSeconds() {
86         return seconds;
87     }
88
89     /**
90      * Sets the seconds value for this WSDate.
91      *
92      * @param seconds
93      */
94     public void setSeconds(int seconds) {
95         this.seconds = seconds;
96     }
97
98     /**
99      * Gets the year value for this WSDate.
100      *
101      * @return year
102      */
103     public int getYear() {
104         return year;
105     }
106
107     /**
108      * Sets the year value for this WSDate.
109      *
110      * @param year
111      */
112     public void setYear(int year) {
113         this.year = year;
114     }
115
116     /**
117      * Gets the day value for this WSDate.
118      *
119      * @return day
120      */
121     public int getDay() {
122         return day;
123     }
124
125     /**
126      * Sets the day value for this WSDate.
127      *
128      * @param day
129      */
130     public void setDay(int day) {
131         this.day = day;
132     }
133
134     /**
135      * Gets the monthWithJanuaryAsOne value for this WSDate.
136      *
137      * @return monthWithJanuaryAsOne
138      */
139     public int getMonthWithJanuaryAsOne() {
140         return monthWithJanuaryAsOne;
141     }
142
143     /**
144      * Sets the monthWithJanuaryAsOne value for this WSDate.
145      *
146      * @param monthWithJanuaryAsOne
147      */
148     public void setMonthWithJanuaryAsOne(int monthWithJanuaryAsOne) {
149         this.monthWithJanuaryAsOne = monthWithJanuaryAsOne;
150     }
151
152     /**
153      * Gets WSDate as LocalDateTime.
154      *
155      * @return LocalDateTime
156      */
157     public LocalDateTime getAsLocalDateTime() {
158         return LocalDateTime.of(year, monthWithJanuaryAsOne, day, hours, minutes, seconds);
159     }
160
161     /**
162      * Gets WSDate as ZonedDateTime.
163      *
164      * @return LocalDateTime
165      */
166     public ZonedDateTime getAsZonedDateTime(ZoneId zoneId) {
167         return ZonedDateTime.of(getAsLocalDateTime(), zoneId);
168     }
169 }