如何在 Neo4J 的 Java 驱动程序中将 DateTime 值作为参数传递?

问题描述

我使用的是 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 DateTimezoneddatetime should be allowed as parameter (here is another hint),但如何正确使用?

或者我必须创建一个this 这样的 DateTime 值:

datetime({year:1984,month:10,day:11,hour:12,timezone: 'Europe/Stockholm'})

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)