org.linkedin.util-core/src/main/java/org/linkedin/util/clock/Timespan.java
public String getAsString(EnumSet<TimeUnit> timeUnits)
  {
    StringBuilder sb = new StringBuilder();

    EnumMap<TimeUnit, Timespan> canonicalTimespans = getAsTimespans(timeUnits);
    for(TimeUnit timeUnit : TIME_UNIT_ORDER)
    {
      if(canonicalTimespans.containsKey(timeUnit))
      {
        long duration = canonicalTimespans.get(timeUnit).getDuration();
        if(duration > 0)
        {
          sb.append(duration).append(timeUnit.getDisplayChar());
        }
      }
    }

    if(sb.length() == 0)
    {
      sb.append(0);
      if(timeUnits.contains(getTimeUnit()))
        sb.append(getTimeUnit().getDisplayChar());
    }

    return sb.toString();
  }
public String getAsString(EnumSet<TimeUnit> timeUnits)
  {
    StringBuilder sb = new StringBuilder();

    EnumMap<TimeUnit, Timespan> canonicalTimespans = getAsTimespans(timeUnits);
    for(TimeUnit timeUnit : TIME_UNIT_ORDER)
    {
      if(canonicalTimespans.containsKey(timeUnit))
      {
        long duration = canonicalTimespans.get(timeUnit).getDuration();
        if(duration > 0)
        {
          sb.append(duration).append(timeUnit.getDisplayChar());
        }
      }
    }

    if(sb.length() == 0)
    {
      sb.append(0);
      if(timeUnits.contains(getTimeUnit()))
        sb.append(getTimeUnit().getDisplayChar());
    }

    return sb.toString();
  }
Returns a string representing this timespan expressed with the units provided.

@param timeUnits the timeunits you want in the decomposition
@return a string representation using the units.
@see #getAsTimespans(EnumSet)