Fixed bug related to the erroneous date presentation when the TV device is linked to a remote UPnP Clock. Changed state variable from time to DateTime. The sample devices are not interoperable with the original Cyberlink devices anymore.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@763994 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockDevice.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockDevice.java
index a03fbd7..8a458b5 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockDevice.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockDevice.java
@@ -22,6 +22,7 @@
import java.beans.PropertyChangeEvent;
import java.util.Calendar;
+import java.util.Date;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
@@ -143,9 +144,9 @@
public void update() {
Clock clock = Clock.getInstance();
Calendar cal = clock.getCalendar();
- long time = cal.getTime().getTime();
+ Date date = cal.getTime();
UPnPStateVariable variable = timerService.getStateVariable("Time");
- notifier.propertyChange(new PropertyChangeEvent(variable,"Time",new Long(time-1000),new Long(time)));
+ notifier.propertyChange(new PropertyChangeEvent(variable,"Time",null,date));
}
}
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java
index 3a49517..ec3a918 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java
@@ -44,14 +44,14 @@
* @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
*/
public Class getJavaDataType() {
- return Long.class;
+ return Date.class;
}
/* (non-Javadoc)
* @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
*/
public String getUPnPDataType() {
- return TYPE_TIME;
+ return TYPE_DATETIME;
}
/* (non-Javadoc)
@@ -105,6 +105,6 @@
}
public Object getCurrentValue() {
- return new Long(clock.getCalendar().getTime().getTime());
+ return clock.getCalendar().getTime();
}
}
diff --git a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java
index 1c43cc6..c2eba36 100644
--- a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java
+++ b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java
@@ -260,8 +260,8 @@
if( !LinkedDevices.contains(deviceId))
LinkedDevices.add(deviceId);
if (deviceId.indexOf("Clock") != -1){
- Long time = (Long) events.get("Time");
- clockTime = new Date(time.longValue()).toString();
+ Date date = (Date) events.get("Time");
+ clockTime = date.toString();
}
else if (deviceId.indexOf("AirCon") != -1)
airconTemp = (String) events.get("Temp");