Restore type adapter for LocalDate (#14897)
Signed-off-by: Mark Hilbush <mark@hilbush.com>
This commit is contained in:
parent
f9cc267190
commit
fd460b9174
@ -21,7 +21,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
*/
|
||||
public class SleepDataSession {
|
||||
|
||||
@SerializedName("avgSleepIQ")
|
||||
@SerializedName("sleepQuotient")
|
||||
private Integer sessionAverageSleepIQ;
|
||||
|
||||
@SerializedName("avgHeartRate")
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.sleepiq.internal.api.impl;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@ -28,6 +29,7 @@ import org.openhab.binding.sleepiq.internal.api.impl.typeadapters.FoundationOutl
|
||||
import org.openhab.binding.sleepiq.internal.api.impl.typeadapters.FoundationOutletTypeAdapter;
|
||||
import org.openhab.binding.sleepiq.internal.api.impl.typeadapters.FoundationPositionTypeAdapter;
|
||||
import org.openhab.binding.sleepiq.internal.api.impl.typeadapters.FoundationPresetTypeAdapter;
|
||||
import org.openhab.binding.sleepiq.internal.api.impl.typeadapters.LocalDateTypeAdapter;
|
||||
import org.openhab.binding.sleepiq.internal.api.impl.typeadapters.SideTypeAdapter;
|
||||
import org.openhab.binding.sleepiq.internal.api.impl.typeadapters.SleepNumberRequestAdapter;
|
||||
import org.openhab.binding.sleepiq.internal.api.impl.typeadapters.TimeSinceTypeAdapter;
|
||||
@ -50,6 +52,7 @@ public class GsonGenerator {
|
||||
public static Gson create(boolean prettyPrint) {
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
builder.registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeTypeAdapter());
|
||||
builder.registerTypeAdapter(LocalDate.class, new LocalDateTypeAdapter());
|
||||
builder.registerTypeAdapter(TimeSince.class, new TimeSinceTypeAdapter());
|
||||
builder.registerTypeAdapter(SleepNumberRequest.class, new SleepNumberRequestAdapter());
|
||||
builder.registerTypeAdapter(Side.class, new SideTypeAdapter());
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2023 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.sleepiq.internal.api.impl.typeadapters;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
||||
/**
|
||||
* Type adapter for jsr310 {@link LocalDate} class.
|
||||
*
|
||||
* @author Christophe Bornet - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class LocalDateTypeAdapter extends TemporalTypeAdapter<LocalDate> {
|
||||
|
||||
public LocalDateTypeAdapter() {
|
||||
super(LocalDate::parse);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user