小编Not*_*tch的帖子

两个本地时间的平均值

如何获得两个的平均值LocalTimes?找不到适合的方法。

因此,例如08:00和14:30,应该返回(14-8)/ 2 = 3 +分钟(30-00 = 30)/ 2,所以3:15然后像

Localtime xxx = LocalTime.parse("08:00", formatter).plus(3, ChronoUnit.HOURS); 
//and after that's done
xxx = xxx.plus(15, ChronoUnit.MINUTES);
Run Code Online (Sandbox Code Playgroud)

现在假设我有以下代码:

   //this means that if code is 08:00, it should look whether the average of Strings split21 and split2 (which are put in time2 and time3, where time2 is ALWAYS before time3) is before 08:00
   if(code1.contains("800")) {

        LocalTime time1 = LocalTime.parse("08:00", formatter);
        LocalTime time2 = LocalTime.parse(split21, formatter);
        LocalTime time3 = LocalTime.parse(split2, formatter);
        LocalTime average = …
Run Code Online (Sandbox Code Playgroud)

java date localtime

2
推荐指数
1
解决办法
223
查看次数

标签 统计

date ×1

java ×1

localtime ×1