/**
* Converts the duration in the format of HH:MM:SS:ss to HH:MM:SS
* @param periodHHMMSSmm
* @return
*/
public static String convertDuration(final String periodHHMMSSmm){
String newDuration = periodHHMMSSmm;
PeriodFormatter hoursMinutesSecondsMilli = new PeriodFormatterBuilder()
.appendHours()
.appendSeparator(":")
.appendMinutes()
.appendSeparator(":")
.appendSeconds()
.appendSeparator(":")
.appendMillis()
.toFormatter();
try{
if (StringUtils.isNotBlank(periodHHMMSSmm)){
Period period = hoursMinutesSecondsMilli.parsePeriod(periodHHMMSSmm);
newDuration = String.format("%02d:%02d:%02d", period.getHours(), period.getMinutes(), period.getSeconds());
}
}catch(IllegalArgumentException e){
log.error("Invalid duration format: " + periodHHMMSSmm);
}
return newDuration;
}
DurationUtils.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:amberdb
作者:
评论列表
文章目录