时间格式化

master
382696293@qq.com 2 years ago
parent 6063b4d5da
commit a5f34fda1f

@ -4,9 +4,8 @@ import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.flossom.common.core.utils.DateUtils;
import com.flossom.common.core.web.domain.BaseEntity; import com.flossom.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/** /**
* wx_instrument * wx_instrument
@ -364,7 +363,7 @@ public class WxInstrument extends BaseEntity {
this.nursingTime = nursingTime; this.nursingTime = nursingTime;
// 将 localTime 转为 分秒 格式 // 将 localTime 转为 分秒 格式
if (nursingTime != null) { if (nursingTime != null) {
this.nursingTimeStr = String.format("%02d:%02d", nursingTime.getMinute(), nursingTime.getSecond()); this.nursingTimeStr = DateUtils.formatMS(nursingTime.getSecond());
} }
} }

@ -463,7 +463,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
// 将 localTime 转为 分秒 格式 // 将 localTime 转为 分秒 格式
if (wxModeRet.getModeTime() != null) { if (wxModeRet.getModeTime() != null) {
wxModeRet.setModeTimeStr(String.format("%02d:%02d", wxModeRet.getModeTime().getMinute(), wxModeRet.getModeTime().getSecond())); wxModeRet.setModeTimeStr(DateUtils.formatMS(wxModeRet.getModeTime().getSecond()));
} }
wxModeRetList.add(wxModeRet); wxModeRetList.add(wxModeRet);
} }

@ -68,17 +68,10 @@ public class WxNursingLogServiceImpl implements IWxNursingLogService {
totalNursingSecond += wxNursingLog.getNursingTime().toSecondOfDay(); totalNursingSecond += wxNursingLog.getNursingTime().toSecondOfDay();
} }
} }
wxNursingStatisticsRet.setNursingTime(formatDuration(totalNursingSecond)); wxNursingStatisticsRet.setNursingTime(DateUtils.formatHMS(totalNursingSecond));
return wxNursingStatisticsRet; return wxNursingStatisticsRet;
} }
return new WxNursingStatisticsRet(0, formatDuration(0)); return new WxNursingStatisticsRet(0, DateUtils.formatHMS(0));
}
private String formatDuration(int seconds) {
int hours = seconds / 3600;
int minutes = (seconds % 3600) / 60;
int remainingSeconds = seconds % 60;
return String.format("%02d:%02d:%02d", hours, minutes, remainingSeconds);
} }
/** /**

Loading…
Cancel
Save