GWT*_*bie 2 java jodatime periodformatter
System.out.println( PeriodFormat.getDefault().print(Period.hours(1).plusMinutes(30).plusSeconds(60)));
Run Code Online (Sandbox Code Playgroud)
上面的Joda PeriodFormatter的输出是"1小时30分60秒".
我知道这是一个边缘情况,但有没有办法输出这个"1小时31分钟"?
谢谢!
您可以先将其标准化为normalizedStandard:
Period period = Period.hours(1).plusMinutes(30).plusSeconds(60);
PeriodFormat.getDefault().print(period.normalizedStandard());
Run Code Online (Sandbox Code Playgroud)
或者可能:
Period period = Period.hours(1).plusMinutes(30).plusSeconds(60);
PeriodFormat.getDefault()
.print(period.normalizedStandard(period.getPeriodType()));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1947 次 |
| 最近记录: |