public static String
format(long ttl) {
	TTL.check(ttl);
	StringBuffer sb = new StringBuffer();
	long secs, mins, hours, days, weeks;
	secs = ttl % 60;
	ttl /= 60;
	mins = ttl % 60;
	ttl /= 60;
	hours = ttl % 24;
	ttl /= 24;
	days = ttl % 7;
	ttl /= 7;
	weeks = ttl;
	if (weeks > 0)
		sb.append(weeks + "W");
	if (days > 0)
		sb.append(days + "D");
	if (hours > 0)
		sb.append(hours + "H");
	if (mins > 0)
		sb.append(mins + "M");
	if (secs > 0 || (weeks == 0 && days == 0 && hours == 0 && mins == 0))
		sb.append(secs + "S");
	return sb.toString();
}
Parses a TTL, which can either be expressed as a number or a BIND-style
string with numbers and units.
@param s The string representing the TTL
@return The TTL as a number of seconds
@throws NumberFormatException The string was not in a valid TTL format.
src/main/java/core/org/xbill/DNS/TTL.java