--- 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 2002/05/18 18:16:03 1.6 @@ -1,5 +1,24 @@ +/* + * i-scream central monitoring system + * Copyright (C) 2000-2002 i-scream + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + //---PACKAGE DECLARATION--- -package uk.org.iscream.util; +package uk.org.iscream.cms.server.util; //---IMPORTS--- import java.util.*; @@ -9,7 +28,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.6 2002/05/18 18:16:03 tdb Exp $ */ public class DateUtils { @@ -18,7 +37,7 @@ public class DateUtils { /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.3 $"; + public final String REVISION = "$Revision: 1.6 $"; public static final long secsPerMonth = 30*24*60*60; public static final long secsPerWeek = 7*24*60*60; @@ -191,6 +210,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 +237,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.org.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