Difference of two Joda LocalDateTimes

前端 未结 4 632
伪装坚强ぢ
伪装坚强ぢ 2020-12-19 01:28

I\'ve got 2 Joda LocalDateTime objects and need to produce a 3rd that represents the difference between them:

LocalDateTime start = getStartLoca         


        
4条回答
  •  执笔经年
    2020-12-19 02:00

    Duration is better for some cases. You can get a "timezone-independent" duration for use with LocalDateTimes (in local time line) by this trick:

    public static Duration getLocalDuration(LocalDateTime start, LocalDateTime end) {
        return new Duration(start.toDateTime(DateTimeZone.UTC), end.toDateTime(DateTimeZone.UTC));
    }
    

提交回复
热议问题