--- projects/cms/source/util/uk/org/iscream/cms/util/DateUtils.java 2001/02/05 22:21:20 1.2 +++ projects/cms/source/util/uk/org/iscream/cms/util/DateUtils.java 2001/05/29 17:02:35 1.5 @@ -1,5 +1,5 @@ //---PACKAGE DECLARATION--- -package uk.ac.ukc.iscream.util; +package uk.org.iscream.cms.server.util; //---IMPORTS--- import java.util.*; @@ -9,7 +9,7 @@ import java.text.*; * Provides easy to use date functions. * * @author $Author: tdb $ - * @version $Id: DateUtils.java,v 1.2 2001/02/05 22:21:20 tdb Exp $ + * @version $Id: DateUtils.java,v 1.5 2001/05/29 17:02:35 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.2 $"; + public final String REVISION = "$Revision: 1.5 $"; 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--- @@ -200,7 +218,7 @@ public class DateUtils { * Overrides the {@link java.lang.Object#toString() Object.toString()} * method to provide clean logging (every class should have this). * - * This uses the uk.ac.ukc.iscream.util.FormatName class + * This uses the uk.org.iscream.cms.server.util.FormatName class * to format the toString() * * @return the name of this class and its CVS revision