add describeDuration

This commit is contained in:
Grahame Grieve 2019-12-09 17:32:52 +11:00
parent 30d7c4ff45
commit 1d751a4c75
1 changed files with 14 additions and 0 deletions

View File

@ -63,12 +63,14 @@ import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.channels.FileChannel;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.hl7.fhir.exceptions.FHIRException;
@ -1223,6 +1225,18 @@ public class Utilities {
return b.toString();
}
public static String describeDuration(Duration d) {
if (d.toDays() > 2) {
return String.format("%s days", d.toDays());
} else if (d.toHours() > 2) {
return String.format("%s hours", d.toHours());
} else if (d.toMinutes() > 2) {
return String.format("%s mins", d.toMinutes());
} else {
return String.format("%s ms", d.toMillis());
}
}
}