Author: sback
Date: 2007-07-03 22:26:03 +0000 (Tue, 03 Jul 2007)
New Revision: 13907
Modified:
trunk/freenet/src/freenet/support/TimeUtil.java
Log:
Now it throws a IllegalArgumentException if the client wants to display more
than 6 terms (which is the maximum)
Modified: trunk/freenet/src/freenet/support/TimeUtil.java
===================================================================
--- trunk/freenet/src/freenet/support/TimeUtil.java 2007-07-03 21:57:27 UTC
(rev 13906)
+++ trunk/freenet/src/freenet/support/TimeUtil.java 2007-07-03 22:26:03 UTC
(rev 13907)
@@ -32,12 +32,17 @@
* @param timeInterval interval to convert
* @param maxTerms the terms number to display
* (e.g. 2 means "h" and "m" if the time could be expressed in hour,
- * 3 means "h","m","s" in the same example)
+ * 3 means "h","m","s" in the same example).
+ * The maximum terms number available is 6
* @param withSecondFractions if true it displays seconds.milliseconds
* @return the formatted String
*/
public static String formatTime(long timeInterval, int maxTerms, boolean
withSecondFractions) {
- StringBuffer sb = new StringBuffer(64);
+
+ if (maxTerms > 6 )
+ throw new IllegalArgumentException();
+
+ StringBuffer sb = new StringBuffer(64);
long l = timeInterval;
int termCount = 0;
//