Browse Source

修改flyTime 转换为时分秒

tags/v1.1.0
wanghaoran 2 years ago
parent
commit
f7d0c5dc48
2 changed files with 7 additions and 2 deletions
  1. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/MissionServiceImpl.java
  2. +6
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/utils/TimeUtil.java

+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/MissionServiceImpl.java View File

List<ThInspection> thInspections = inspectionMapper.selectList(lambdaInspection); List<ThInspection> thInspections = inspectionMapper.selectList(lambdaInspection);
if (ObjectUtil.isNotEmpty(thInspections) && thInspections.size() > 0) { if (ObjectUtil.isNotEmpty(thInspections) && thInspections.size() > 0) {
ThInspection temp = thInspections.get(0); ThInspection temp = thInspections.get(0);
missionVO.setFlyTime(TimeUtil.getFormatFlyTime(temp.getFlyTime()));
missionVO.setFlyTime(TimeUtil.getFormatFlyTime(temp.getFlyTime() * 1000));
} }
} }
} }

+ 6
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/utils/TimeUtil.java View File



public class TimeUtil { public class TimeUtil {


/**
*
* @param milliseconds 毫秒
* @return
*/
public static String getFormatFlyTime(long milliseconds){ public static String getFormatFlyTime(long milliseconds){


long day = TimeUnit.MILLISECONDS.toDays(milliseconds); long day = TimeUnit.MILLISECONDS.toDays(milliseconds);


long seconds = TimeUnit.MILLISECONDS.toSeconds(milliseconds) long seconds = TimeUnit.MILLISECONDS.toSeconds(milliseconds)
- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds)); - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds));
System.out.println("milliseconds :-" + milliseconds);
System.out.println("milliseconds :" + milliseconds);


if(day!=0L){ if(day!=0L){
return String.format("%d 天 %d 时 %d 分 %d 秒", day, hours, minutes, seconds); return String.format("%d 天 %d 时 %d 分 %d 秒", day, hours, minutes, seconds);

Loading…
Cancel
Save