18:05, EEST
August 20, 2014
Hi,
i was doing some tests with an OPC UA Server and variables. I tried to set a DateTime variable, but i’m not able to do it. I want to initialize the variable with e.g. the date: Wednesday, 12. July 2017 09:37:27.995, which is in ms: 1499852247995.
This is the code to initialize the variable:
CacheVariable dateTime = new CacheVariable(this, new NodeId(2, “DateTimeId”),”DateTime”, LocalizedText.NO_LOCALE);
dateTime.setDataType(getServer().getNodeManagerRoot().getType(Identifiers.DateTime));
long date = 1499852247995L;
dateTime.setValue(new DataValue(new Variant(new DateTime(date))));
methodsFolder.addComponent(dateTime);
if i start the server and take a look at this variabel i see the follwoing date:
2000-01-01T00:00:00.000Z
what is wrong with my code?
Thanks.
Ibrahim
18:40, EEST
December 21, 2011
The constructor is not expecting milliseconds.
* Constructs a new DateTime value, initializing it with an OPC UA time value with a resolution of 100 nanoseconds.
*/
public DateTime(long value);
Instead, you should use ‘DateTime dt = DateTime.fromMillis(date);’, if you want to initialise it from milliseconds.
Most Users Ever Online: 1919
Currently Online:
21 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 730
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25ZofModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1