Avatar
Please consider registering
guest
sp_LogInOut Log Insp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSSsp_TopicIcon
DateTime.parseDateTime(string) does not parse nanoseconds
October 12, 2020
15:46, EEST
Avatar
Christv
Member
Members
Forum Posts: 9
Member Since:
August 9, 2016
sp_UserOfflineSmall Offline

when using a string like “2020-10-07 14:43:00.017” or “2020-10-07 14:43:00.0170000” with DateTime.parseDateTime the nanoseconds are lost

October 12, 2020
16:44, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1045
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

As per javadocs, that method only supports parsing to the second level.

I believe the reason to be originating from https://reference.opcfoundatio…..1/#5.3.1.6, “A DateTime value is encoded as an xs:dateTime value.”,
https://www.w3schools.com/xml/…..s_date.asp only shows second-level resolution on xs:dateTime.

As a personal opinion, where possible, I would recommend to use Java 8 time APIs (e.g. java.time.Instant) instead, and do a conversion on the boundary where you call SDK methods. If you convert to DataValue use-cases, note that UA DateTime is resolution of 100s of nanoseconds (source and serverTimestamp), the rest is 10s of picoseconds (source and serverPicoseconds), see https://reference.opcfoundatio…..rt4/7.7.1/ for more info. Also read the javadocs of each methods in DateTime you call, since some assume java epoch (unix epoch) and others “UA Epoch” (or “windows epoch”;https://en.wikipedia.org/wiki/…..computing) ).

Forum Timezone: Europe/Helsinki
Most Users Ever Online: 1919
Currently Online:
Guest(s) 13
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 90
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 733
Moderators: 8
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1545
Posts: 6516
Newest Members:
basilpullman, Richardmip, mood edibles, LouieWreve, daniellabdx, janessan21, sammiebeak359, gena7127517, thorstenbouldin, Brett.Rollason
Moderators: Jouni Aro: 1029, Pyry: 1, Petri: 1, Bjarne Boström: 1045, Jimmy Ni: 26, Matti Siponen: 353, Lusetti: 0, Elias: 0
Administrators: admin: 1