我正在使用 Neo4J Java 驱动程序
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>4.2.0</version>
</dependency>
我正在尝试使用 DateTime 值作为参数映射中的值,大致如下:
// we have a timezone, unixTimestamp as epoch seconds and a simple key: "d"
final Instant instant = Instant.ofEpochSecond(unixTimestamp);
final ZoneId zoneId = ZoneId.of(timezone);
final ZonedDateTime zonedValueDate = ZonedDateTime.ofInstant(instant, zoneId);
// creating a DateTimeValue from zonedValueDate does not work either
return Map.of(key, zonedValueDate);
此地图用于TransactionWork
类似的实例
public Map<String,Object> execute(Transaction tx) {
Result queryResult = tx.run(query, parameter);
// consuming results ...
// returning them as Map
}
但我遇到了一个例外:
org.neo4j.driver.exceptions.ClientException: Property values can only be of primitive types or arrays thereof
A DateTime
orZonedDateTime
应该被允许作为参数(这里是另一个提示),但是如何正确使用它呢?
还是我必须像这样创建一个 DateTime值:
datetime({year:1984, month:10, day:11, hour:12, timezone: 'Europe/Stockholm'})