Please consider registering

sp_LogInOut Log In sp_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 RSS sp_TopicIcon
DateTime.parseDateTime(string) does not parse nanoseconds
October 12, 2020
15:46, EEST
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
Bjarne Boström
Forum Posts: 559
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline


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

I believe the reason to be originating from https://reference.opcfoundation.org/v104/Core/docs/Part6/5.3.1/#, “A DateTime value is encoded as an xs:dateTime value.”,
https://www.w3schools.com/xml/schema_dtypes_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.opcfoundation.org/v104/Core/docs/Part4/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/Epoch_(computing) ).

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 267

Currently Online:
12 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 103

pramanj: 86

ibrahim: 70

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 38

Rainer Versteeg: 32

Thomas Reuther: 31

Member Stats:

Guest Posters: 0

Members: 1118

Moderators: 14

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1034

Posts: 4352

Newest Members:

aldayr, Python techie, emanuel45q, Patrick, sammycontrols, hellema, linoy, subranna, ray, richN9177

Moderators: Jouni Aro: 853, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 559, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 21, Markus Johansson: 24, Matti Siponen: 64, Lusetti: 0

Administrators: admin: 1