I am facing a problem for which I turn to the community for help.
I have created a Fake Graph in python using the driver I normally install pip install neo4j
I have a node with a property of type datetime and when I try to load the data from the backend of the project in java with Spring Boot it gives me this error:
org.neo4j.driver.exceptions.value.Uncoercible: Cannot coerce STRING to LocalDateTime
In python to try to correct this error I ran this code:
conn.query("""
MATCH (r:Review)
set r.dateTimeMoment = apoc.date.format(datetime(r.dateTimeMoment).epochMillis, "ms", "yyyy-MM-dd'T'HH:mm:ss")
""")
but the problem of reading date type data from spring data persists.
In the node model in java my property is declared like this: private LocalDateTime dateTimeMoment;
That apoc method converts a date string in one format to another date string in a different format, so it will not do what you want.
If you are trying to extract the value into a LocalDateTime value in java, then you should save the value as a timestamp in Neo4j. Assuming the issue is due to the date being stored as a string representation, convert it to a date time by passing the string value to datetime.
MATCH (r:Review) set r.dateTimeMoment = datetime(r.dateTimeMoment)
Thanks, i used your code and the error change to this new message: org.neo4j.driver.exceptions.value.Uncoercible: Cannot coerce DATE_TIME to LocalDateTime
Sorry, try 'localdatetime' if you want your java type to be an instance of LocalDateTime. Use 'datetime' if you type your java object to ZonedDateTime instead.