You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java Duration计算结果与Excel不一致,求原因排查

求助:Java计算LocalDateTime差值和Excel结果不一致,求排查原因

大家好,我最近遇到个头疼的问题,想请懂行的朋友帮忙分析下:我写了个Java方法用来计算两个LocalDateTime的时间差,同时在Excel里准备了测试数据,但两边算出来的结果对不上。我猜测是Excel的公式出了问题,麻烦帮忙排查下原因。

我的Java方法代码

private Duration difference(LocalDateTime request, LocalDateTime response) {
    Duration duration = Duration.between(request, response);
    System.out.println("difference: " + duration.toMillis());
    return duration;
}

测试数据与两边结果

  • 请求时间:2018-02-12T13:43:46.456
  • 响应时间:2018-02-12T14:43:54.123
  • Excel公式计算结果:3608333 毫秒
  • Java方法计算结果:3607667 毫秒

补充说明

我用的Excel公式是之前找到的公认方案,但现在和Java的计算结果差了666毫秒,实在搞不懂哪里出问题了,麻烦各位帮忙看看!

内容的提问来源于stack exchange,提问作者TheCoder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:32:22