JodaTime-将秒数转换为年/日/小时/分钟
jodatime依赖
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.10</version>
</dependency>
Seconds seconds = Seconds.seconds(898298);
Period period = new Period(seconds);
PeriodFormatter periodFormatter = new PeriodFormatterBuilder()
.appendDays()
.appendSuffix("天")
.appendSeparator(" ")
.appendHours()
.appendSuffix("小时")
.appendSeparator(" ")
.appendMinutes()
.appendSuffix("分钟")
.appendSeparator(" ")
.appendSeconds()
.appendSuffix("秒").toFormatter();
System.out.println(periodFormatter.print(period.normalizedStandard()));
效果:
3天 9小时 31分钟 38秒
还没有评论,来说两句吧...