mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Refactor java.util.Date usages to java.time.Instant (#16239)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
e759c85353
commit
bf139b0ef2
@ -16,7 +16,7 @@ import static org.openhab.binding.asuswrt.internal.constants.AsuswrtBindingConst
|
||||
import static org.openhab.binding.asuswrt.internal.constants.AsuswrtBindingSettings.*;
|
||||
import static org.openhab.binding.asuswrt.internal.helpers.AsuswrtUtils.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -95,7 +95,7 @@ public class AsuswrtDiscoveryService extends AbstractThingHandlerDiscoveryServic
|
||||
* Removes all scan results.
|
||||
*/
|
||||
private void removeAllResults() {
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
package org.openhab.binding.boschshc.internal.discovery;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -112,7 +112,7 @@ public class ThingDiscoveryService extends AbstractThingHandlerDiscoveryService<
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
logger.trace("dispose");
|
||||
removeOlderResults(new Date().getTime(), thingHandler.getThing().getUID());
|
||||
removeOlderResults(Instant.now().toEpochMilli(), thingHandler.getThing().getUID());
|
||||
thingHandler.unregisterDiscoveryListener();
|
||||
|
||||
super.deactivate();
|
||||
|
@ -14,7 +14,7 @@ package org.openhab.binding.bticinosmarther.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.bticinosmarther.internal.SmartherBindingConstants.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -86,7 +86,7 @@ public class SmartherModuleDiscoveryService extends AbstractThingHandlerDiscover
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
logger.debug("Bridge[{}] Deactivating chronothermostat discovery service", this.bridgeUID);
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,7 @@ package org.openhab.binding.deconz.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.deconz.internal.BindingConstants.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -298,6 +298,6 @@ public class ThingDiscoveryService extends AbstractThingHandlerDiscoveryService<
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ package org.openhab.binding.digitalstrom.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants.BINDING_ID;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -76,7 +76,7 @@ public class DeviceDiscoveryService extends AbstractDiscoveryService {
|
||||
public void deactivate() {
|
||||
logger.debug("deactivate discovery service for device type {} thing types are: {}", deviceType,
|
||||
super.getSupportedThingTypes().toString());
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,8 +17,8 @@ import static org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConst
|
||||
import static org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants.SCENE_ID;
|
||||
import static org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants.ZONE_ID;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -73,7 +73,7 @@ public class SceneDiscoveryService extends AbstractDiscoveryService {
|
||||
public void deactivate() {
|
||||
logger.debug("deactivate discovery service for scene type {} remove thing tyspes {}", sceneType,
|
||||
super.getSupportedThingTypes());
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,8 +14,8 @@ package org.openhab.binding.digitalstrom.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants.BINDING_ID;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -77,7 +77,7 @@ public class ZoneTemperatureControlDiscoveryService extends AbstractDiscoverySer
|
||||
public void deactivate() {
|
||||
logger.debug("Deactivate discovery service for zone teperature control type remove thing types {}",
|
||||
super.getSupportedThingTypes());
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.gpstracker.internal.discovery;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -117,7 +117,7 @@ public class TrackerDiscoveryService extends AbstractDiscoveryService {
|
||||
@Override
|
||||
@Deactivate
|
||||
protected void deactivate() {
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ package org.openhab.binding.hue.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.hue.internal.HueBindingConstants.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
@ -83,7 +83,7 @@ public class Clip2ThingDiscoveryService extends AbstractThingHandlerDiscoverySer
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
thingHandler.unregisterDiscoveryService();
|
||||
removeOlderResults(new Date().getTime(), thingHandler.getThing().getBridgeUID());
|
||||
removeOlderResults(Instant.now().toEpochMilli(), thingHandler.getThing().getBridgeUID());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,8 +14,8 @@ package org.openhab.binding.hue.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.hue.internal.HueBindingConstants.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -127,7 +127,7 @@ public class HueDeviceDiscoveryService extends AbstractThingHandlerDiscoveryServ
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
removeOlderResults(new Date().getTime(), bridgeUID);
|
||||
removeOlderResults(Instant.now().toEpochMilli(), bridgeUID);
|
||||
thingHandler.unregisterDiscoveryListener();
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.hydrawise.internal.discovery;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -56,7 +56,7 @@ public class HydrawiseCloudControllerDiscoveryService
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
removeOlderResults(new Date().getTime(), thingHandler.getThing().getUID());
|
||||
removeOlderResults(Instant.now().toEpochMilli(), thingHandler.getThing().getUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,7 @@ package org.openhab.binding.livisismarthome.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.livisismarthome.internal.LivisiBindingConstants.PROPERTY_ID;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@ -65,7 +65,7 @@ public class LivisiDeviceDiscoveryService extends AbstractThingHandlerDiscoveryS
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.max.internal.discovery;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@ -60,7 +60,7 @@ public class MaxDeviceDiscoveryService extends AbstractThingHandlerDiscoveryServ
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
thingHandler.unregisterDeviceStatusListener(this);
|
||||
removeOlderResults(new Date().getTime(), thingHandler.getThing().getUID());
|
||||
removeOlderResults(Instant.now().toEpochMilli(), thingHandler.getThing().getUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,8 +15,8 @@ package org.openhab.binding.mihome.internal.discovery;
|
||||
import static org.openhab.binding.mihome.internal.ModelMapper.*;
|
||||
import static org.openhab.binding.mihome.internal.XiaomiGatewayBindingConstants.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -86,7 +86,7 @@ public class XiaomiItemDiscoveryService extends AbstractDiscoveryService impleme
|
||||
}
|
||||
|
||||
public void onHandlerRemoved() {
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.mqtt.discovery;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -139,7 +139,7 @@ public abstract class AbstractMQTTDiscovery extends AbstractDiscoveryService imp
|
||||
@Override
|
||||
protected void startBackgroundDiscovery() {
|
||||
// Remove results that are restored after a restart
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
subscribe();
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MulticastSocket;
|
||||
import java.time.Duration;
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -72,7 +72,7 @@ public class NoboHubDiscoveryService extends AbstractThingHandlerDiscoveryServic
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
}
|
||||
|
||||
private final Runnable scanner = new Runnable() {
|
||||
|
@ -22,8 +22,8 @@ import static org.openhab.binding.nobohub.internal.NoboHubBindingConstants.PROPE
|
||||
import static org.openhab.binding.nobohub.internal.NoboHubBindingConstants.THING_TYPE_COMPONENT;
|
||||
import static org.openhab.binding.nobohub.internal.NoboHubBindingConstants.THING_TYPE_ZONE;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -71,7 +71,7 @@ public class NoboThingDiscoveryService extends AbstractDiscoveryService {
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
}
|
||||
|
||||
public void detectZones(Collection<Zone> zones) {
|
||||
|
@ -14,7 +14,7 @@ package org.openhab.binding.onewire.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.onewire.internal.OwBindingConstants.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -134,6 +134,6 @@ public class OwDiscoveryService extends AbstractThingHandlerDiscoveryService<Ows
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ package org.openhab.binding.openweathermap.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.openweathermap.internal.OpenWeatherMapBindingConstants.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@ -72,7 +72,7 @@ public class OpenWeatherMapDiscoveryService extends AbstractDiscoveryService {
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
removeOlderResults(new Date().getTime(), bridgeHandler.getThing().getUID());
|
||||
removeOlderResults(Instant.now().toEpochMilli(), bridgeHandler.getThing().getUID());
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,8 @@ package org.openhab.binding.touchwand.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.touchwand.internal.TouchWandBindingConstants.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@ -137,14 +137,14 @@ public class TouchWandUnitDiscoveryService extends AbstractThingHandlerDiscovery
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
removeOlderResults(new Date().getTime(), thingHandler.getThing().getUID());
|
||||
removeOlderResults(Instant.now().toEpochMilli(), thingHandler.getThing().getUID());
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
removeOlderResults(new Date().getTime(), thingHandler.getThing().getUID());
|
||||
removeOlderResults(Instant.now().toEpochMilli(), thingHandler.getThing().getUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,7 @@ package org.openhab.binding.tr064.internal;
|
||||
|
||||
import static org.openhab.binding.tr064.internal.Tr064BindingConstants.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -52,7 +52,7 @@ public class Tr064DiscoveryService extends AbstractThingHandlerDiscoveryService<
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
removeOlderResults(new Date().getTime(), thingHandler.getThing().getUID());
|
||||
removeOlderResults(Instant.now().toEpochMilli(), thingHandler.getThing().getUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,9 +15,9 @@ package org.openhab.binding.tradfri.internal.discovery;
|
||||
import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;
|
||||
import static org.openhab.core.thing.Thing.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -91,7 +91,7 @@ public class TradfriDiscoveryService extends AbstractThingHandlerDiscoveryServic
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
thingHandler.unregisterDeviceUpdateListener(this);
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,8 @@ package org.openhab.binding.velbus.internal.discovery;
|
||||
|
||||
import static org.openhab.binding.velbus.internal.VelbusBindingConstants.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -61,7 +61,7 @@ public class VelbusThingDiscoveryService extends AbstractThingHandlerDiscoverySe
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
removeOlderResults(new Date().getTime());
|
||||
removeOlderResults(Instant.now().toEpochMilli());
|
||||
thingHandler.clearDefaultPacketListener();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user