bayard 2004/09/26 20:30:10 Modified: lang/src/java/org/apache/commons/lang/time DurationFormatUtils.java Log: updated javadoc Revision Changes Path 1.16 +53 -21 jakarta-commons/lang/src/java/org/apache/commons/lang/time/DurationFormatUtils.java Index: DurationFormatUtils.java =================================================================== RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/time/DurationFormatUtils.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- DurationFormatUtils.java 27 Sep 2004 03:14:15 -0000 1.15 +++ DurationFormatUtils.java 27 Sep 2004 03:30:10 -0000 1.16 @@ -21,7 +21,18 @@ import java.util.TimeZone; /** - *

Duration formatting utilities and constants.

+ *

Duration formatting utilities and constants. The following table describes the tokens + * used in the pattern language for formatting.

+ * + * + * + * + * + * + * + * + * + *
characterduration element
yyears
Mmonths
ddays
Hhours
mminutes
sseconds
Smilliseconds
* * @author Apache Ant - DateUtils * @author Stephane Bailliez @@ -83,29 +94,29 @@ public static String formatISO(long millis) { return format(millis, "H:mm:ss.SSS"); } + /** - *

Get the time gap as a string, using the specified format.

- * - * - * - * - * - * - * - * - * - *
characterduration element
yyears (aka 365 days)
Mmonths (aka year/12)
ddays
Hhours
mminutes
sseconds
Smilliseconds
+ *

Get the time gap as a string, using the specified format, and padding with zeros and + * using the default timezone.

* * @param millis the duration to format - * @param format the way iin which to format the duration + * @param format the way in which to format the duration * @return the time as a String */ public static String format(long millis, String format) { return format(millis, format, true); } - public static String format(long millis, String format, boolean padWithZeros) { - return format(millis, format, padWithZeros, TimeZone.getDefault()); - } + /** + *

Get the time gap as a string, using the specified format. + * Padding the left hand side of numbers with zeroes is optional and + * the timezone may be specified. + * + * @param millis the duration to format + * @param format the way in which to format the duration + * @param padWithZeros whether to pad the left hand side of numbers with 0's + * @param timezone the millis are defined in + * @return the time as a String + */ public static String format(long millis, String format, boolean padWithZeros, TimeZone timezone) { if(millis > 28 * DateUtils.MILLIS_PER_DAY) { @@ -164,8 +175,8 @@ } - private static String formatDuration(Token[] tokens, int years, int months, int days, int hours, - int minutes, int seconds, int milliseconds, boolean padWithZeros) + static String formatDuration(Token[] tokens, int years, int months, int days, int hours, + int minutes, int seconds, int milliseconds, boolean padWithZeros) { StringBuffer buffer = new StringBuffer(); int sz = tokens.length; @@ -203,10 +214,31 @@ return buffer.toString(); } - // slower than the above I presume + /** + *

Get the time gap as a string, using the specified format. + * Padding the left hand side of numbers with zeroes is optional. + * + * @param startMillis the start of the duration + * @param endMillis the end of the duration + * @param format the way in which to format the duration + * @param padWithZeros whether to pad the left hand side of numbers with 0's + * @return the time as a String + */ public static String format(long startMillis, long endMillis, String format, boolean padWithZeros) { return format(startMillis, endMillis, format, padWithZeros, TimeZone.getDefault()); } + /** + *

Get the time gap as a string, using the specified format. + * Padding the left hand side of numbers with zeroes is optional and + * the timezone may be specified. + * + * @param startMillis the start of the duration + * @param endMillis the end of the duration + * @param format the way in which to format the duration + * @param padWithZeros whether to pad the left hand side of numbers with 0's + * @param timezone the millis are defined in + * @return the time as a String + */ public static String format(long startMillis, long endMillis, String format, boolean padWithZeros, TimeZone timezone) { long millis = endMillis - startMillis; @@ -271,7 +303,7 @@ // Reduces by difference, then if it overshot, calculates the overshot amount and // fixes and returns the amount to change by - private static int reduceAndCorrect(Calendar start, Calendar end, int field, int difference) { + static int reduceAndCorrect(Calendar start, Calendar end, int field, int difference) { end.add( field, -1 * difference ); int endValue = end.get(field); int startValue = start.get(field); --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org