Author: zothar
Date: 2007-06-21 22:44:55 +0000 (Thu, 21 Jun 2007)
New Revision: 13702
Modified:
trunk/freenet/src/freenet/support/TimeUtil.java
Log:
indent
Modified: trunk/freenet/src/freenet/support/TimeUtil.java
===================================================================
--- trunk/freenet/src/freenet/support/TimeUtil.java 2007-06-21 22:40:24 UTC
(rev 13701)
+++ trunk/freenet/src/freenet/support/TimeUtil.java 2007-06-21 22:44:55 UTC
(rev 13702)
@@ -25,72 +25,72 @@
* Formats milliseconds into a week/day/hour/second/milliseconds string.
*/
public class TimeUtil {
- public static String formatTime(long timeInterval, int maxTerms,
boolean withSecondFractions) {
- StringBuffer sb = new StringBuffer(64);
- long l = timeInterval;
- int termCount = 0;
- //
- int weeks = (int)(l / ((long)7*24*60*60*1000));
- if (weeks > 0) {
+ public static String formatTime(long timeInterval, int maxTerms, boolean
withSecondFractions) {
+ StringBuffer sb = new StringBuffer(64);
+ long l = timeInterval;
+ int termCount = 0;
+ //
+ int weeks = (int)(l / ((long)7*24*60*60*1000));
+ if (weeks > 0) {
sb.append(weeks).append('w');
- termCount++;
- l = l - ((long)weeks * ((long)7*24*60*60*1000));
- }
- //
- int days = (int)(l / ((long)24*60*60*1000));
- if (days > 0) {
+ termCount++;
+ l = l - ((long)weeks * ((long)7*24*60*60*1000));
+ }
+ //
+ int days = (int)(l / ((long)24*60*60*1000));
+ if (days > 0) {
sb.append(days).append('d');
- termCount++;
- l = l - ((long)days * ((long)24*60*60*1000));
- }
- if(termCount >= maxTerms) {
- return sb.toString();
- }
- //
- int hours = (int)(l / ((long)60*60*1000));
- if (hours > 0) {
+ termCount++;
+ l = l - ((long)days * ((long)24*60*60*1000));
+ }
+ if(termCount >= maxTerms) {
+ return sb.toString();
+ }
+ //
+ int hours = (int)(l / ((long)60*60*1000));
+ if (hours > 0) {
sb.append(hours).append('h');
- termCount++;
- l = l - ((long)hours * ((long)60*60*1000));
- }
- if(termCount >= maxTerms) {
- return sb.toString();
- }
- //
- int minutes = (int)(l / ((long)60*1000));
- if (minutes > 0) {
+ termCount++;
+ l = l - ((long)hours * ((long)60*60*1000));
+ }
+ if(termCount >= maxTerms) {
+ return sb.toString();
+ }
+ //
+ int minutes = (int)(l / ((long)60*1000));
+ if (minutes > 0) {
sb.append(minutes).append('m');
- termCount++;
- l = l - ((long)minutes * ((long)60*1000));
- }
- if(termCount >= maxTerms) {
- return sb.toString();
- }
- if(withSecondFractions && ((maxTerms - termCount) >= 2)) {
- if (l > 0) {
- double fractionalSeconds = ((double) l) /
((double) 1000.0);
- DecimalFormat fix3 = new DecimalFormat("0.000");
+ termCount++;
+ l = l - ((long)minutes * ((long)60*1000));
+ }
+ if(termCount >= maxTerms) {
+ return sb.toString();
+ }
+ if(withSecondFractions && ((maxTerms - termCount) >= 2)) {
+ if (l > 0) {
+ double fractionalSeconds = ((double) l) / ((double) 1000.0);
+ DecimalFormat fix3 = new DecimalFormat("0.000");
sb.append(fix3.format(fractionalSeconds)).append('s');
- termCount++;
- //l = l - ((long)fractionalSeconds *
(long)1000);
- }
- } else {
- int seconds = (int)(l / (long)1000);
- if (seconds > 0) {
+ termCount++;
+ //l = l - ((long)fractionalSeconds * (long)1000);
+ }
+ } else {
+ int seconds = (int)(l / (long)1000);
+ if (seconds > 0) {
sb.append(seconds).append('s');
- termCount++;
- //l = l - ((long)seconds * (long)1000);
- }
- }
- //
- return sb.toString();
- }
-
- public static String formatTime(long timeInterval) {
- return formatTime(timeInterval, 2, false);
- }
-
- public static String formatTime(long timeInterval, int maxTerms) {
- return formatTime(timeInterval, maxTerms, false);
- }
+ termCount++;
+ //l = l - ((long)seconds * (long)1000);
+ }
+ }
+ //
+ return sb.toString();
+ }
+
+ public static String formatTime(long timeInterval) {
+ return formatTime(timeInterval, 2, false);
+ }
+
+ public static String formatTime(long timeInterval, int maxTerms) {
+ return formatTime(timeInterval, maxTerms, false);
+ }
}