19 package org.turro.elephant.util;
21 import java.util.Date;
22 import org.amic.util.string.ShowDuration;
23 import org.turro.string.Strings;
24 import org.turro.i18n.I_;
32 public static String
format(Date begin, Date end) {
33 return replaceMacros(
new ShowDuration(begin, end).toString());
36 public static String
format(
long hours) {
37 return replaceMacros(
new ShowDuration(hours).toString());
40 private static String replaceMacros(String duration) {
41 if(!Strings.isEmpty(duration)) {
42 return duration.replaceAll(
"\\$hours",
I_.
get(
"Hours"))
43 .replaceAll(
"\\$days",
I_.
get(
"Days"))
44 .replaceAll(
"\\$months",
I_.
get(
"Months"))
45 .replaceAll(
"\\$years",
I_.
get(
"lYears"));
50 private DurationFormats() {
static String get(String msg)