Joda time はそれをかなり簡単に行います。
例えば:
public static void main(String[] args) {
PeriodFormatter daysHoursMinutes = new PeriodFormatterBuilder()
.appendDays()
.appendSuffix(" day", " days")
.appendSeparator(" and ")
.appendMinutes()
.appendSuffix(" minute", " minutes")
.appendSeparator(" and ")
.appendSeconds()
.appendSuffix(" second", " seconds")
.toFormatter();
Period period = new Period(72, 24, 12, 0);
System.out.println(daysHoursMinutes.print(period));
System.out.println(daysHoursMinutes.print(period.normalizedStandard()));
}
印刷します:
24 minutes and 12 seconds
3 days and 24 minutes and 12 seconds
参照:ピリオドから文字列へ