most of my graph uses the datetime() function (Timestamp:datetime()) to create timestamps on (in) my Neo4j Nodes, which works great.datetime() creates a ZonedDateTime, which is fine and looks like this
Some nodes in my graph use my java code to create timestamp. My java code also uses ZonedDataTime as show here:
my java code returns this:
timeStamp:2023-07-05T10:12:33.271299900-04:00[America/New_York]
if you notice.. they are different and this difference is causing me a lot of .. problems. LocalDataTime and not be cast to ZonedDataTime.. so.. how do I make everything Neo4j ZonedDataTime in my java code?..
Here is the output from apoc.meta.nodetypeProperties.. you can see the DateTime in my working graph..
graph processing is done in Java.. so.. that is where the casting exception happens.. I have java code that looks at, and compares these timestamps and rolls up the newer ones.. basically.. when something gets updated propagate its new timestamp up the chain
so I create some nodes rom within Java and .. blammo that is where these odd timestamps are coming from.. java created nodes have non friendly neo timestamps.. make some sense?
if I use the datetime() function in Neo (cypher script or otherwise) it creates a DateTime field, which it should.. :)
if you grab that node in/from java you get a Zone Data Time element, fine.
now if you then from within java (business logic say) create a ZoneDataTime object and put that into a node, Neo4j doesn't create ZoneDataTime, it creates something else. so.. now my graph nodes are not compatible with each other.
how do I, from within java, add/update/etc. a ZoneDataTime into my graph.. See ?
I am running 5.9.0.. the latest version, as far as I know..
cypherUpdateLeafNodeCommand, for this example, just have it do a simple merge command with two params, the timestamp and the node name (label) .. I am doing a match a set command for the timestamp, I dont think it matters. Just create a node using these two differenet (datetime() and this java method) and you will see (I think) the problem.. if you do that same command in the new browser and use the datetime() function (and a different node label name) you will get two different timestamp formats.. that are not compatible.
cypherUpdateLeafNodeCommand: match (n:Node) where n.Name = $nodeName set n.Timestamp = $Timestamp
hope this helps explain things.. thanks man for helping me out.. sigh.. tight deadlines and.. sigh
I am not doing this.. let me try this Tonight.. I am just using the timestamp from ZoneDateTime.now. Didnt know you could pass that into datetime function..
THANKS MAN!.
Let me try this tonight!
okay. I am not longer crashing so.. THANKS!.. please one follow-up question, if you could Dave. BACKGROUND:
as I was saying.. TimeStamps, in my graph, depending on the node's type, come from either an apoc script datetime(), or from java (using your datetime upgrade). While the timestamp values between these two are compatible (I dont crash), their formats (in the browner and/or apoc.export.csv.query are different so client side systems might get messed up.. Question:
How do I make the datetime() function in my apoc.merge.node and the Java datetime(passed in Java Time Stamp) have the same format?
see what I am asking? I will change either one, just... ??
sure Captain.. Basically my processing mechanisms (TimeStamp rollup and all that) work with both formats but.. you know.. having two different formats for the same thing in a system (graph) is.. kind of odd... you know..
Some node Timestamps look like this and others look like this (see image)..
Some nodes are created from that apoc.export export script datetime(Timestamp) (your mechanism which works great), while others for various reasons are create using a script of apoc.merge.node and the datetime() function.. hope this makes some kind of sense.. THANKS MAN!
Whenever you get a chance.. have fun on vacation.. i have plenty of work to do.. so.. no problem. thanks man.. maybe i do a datetime(currentTime) in the apoc script? that would work.. so.. how do i get the current time in an apoc script.. I will hunt for that. ..
The difference between those two formats is timezone. One is specifying time using eastern time zone while the other is using UTC time. They both work since they represent the instance of time when you captured the time, just in different timezone.
In the java code when you use ZoneDateTime you can specify a time zone. Here is an example java code getting the current instance in eastern time zone format.