【发布时间】:2021-12-28 17:25:27
【问题描述】:
直到现在我还在使用
val date = Instant.now(Clock.system(ZoneId.of("UTC")))
生成即时时间戳。 现在我需要用我想要指定的日期替换它,例如“2021-05-03T00:00:00.000Z”。当我将它作为字符串插入函数时,这个想法给了我错误“类型不匹配。必需:即时!找到:字符串”。我无法更改该功能,因为我无法访问它。所以我需要以某种方式把这个日期变成“即时!”类。
这就是我无法更改的功能的样子
public TimeTZ(Instant timestamp, Boolean isLocal) {
this.timestamp = timestamp;
this.isLocal = isLocal;
}
【问题讨论】:
标签: date kotlin java-time java.time.instant