--- projects/cms/source/util/uk/org/iscream/cms/util/DateUtils.java 2001/03/14 23:25:29 1.3 +++ projects/cms/source/util/uk/org/iscream/cms/util/DateUtils.java 2001/03/16 17:14:23 1.4 @@ -9,7 +9,7 @@ import java.text.*; * Provides easy to use date functions. * * @author $Author: tdb $ - * @version $Id: DateUtils.java,v 1.3 2001/03/14 23:25:29 tdb Exp $ + * @version $Id: DateUtils.java,v 1.4 2001/03/16 17:14:23 tdb Exp $ */ public class DateUtils { @@ -18,7 +18,7 @@ public class DateUtils { /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.3 $"; + public final String REVISION = "$Revision: 1.4 $"; public static final long secsPerMonth = 30*24*60*60; public static final long secsPerWeek = 7*24*60*60; @@ -191,6 +191,24 @@ public class DateUtils { return layout; } + /** + * Takes a time period in seconds and converts it to a + * reasonable message. + * + * @param time the time period in seconds + * @return a String respresentation of the given time period + */ + public static String getTimeString(long time) { + String timeString = null; + if (time >= 3600) { + timeString = ((time/60) / 60) + " hour(s)"; + } else if (time >= 60) { + timeString = (time / 60) + " minute(s)"; + } else { + timeString = time + " second(s)"; + } + return timeString; + } //---CONSTRUCTORS---