commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/time DurationFormatUtils.java
Date Mon, 27 Sep 2004 03:30:10 GMT
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;
   
   /**
  - * <p>Duration formatting utilities and constants.</p>
  + * <p>Duration formatting utilities and constants. The following table describes
the tokens 
  + * used in the pattern language for formatting. </p>
  + * <table border="1">
  + *  <tr><th>character</th><th>duration element</th></tr>
  + *  <tr><td>y</td><td>years</td></tr>
  + *  <tr><td>M</td><td>months</td></tr>
  + *  <tr><td>d</td><td>days</td></tr>
  + *  <tr><td>H</td><td>hours</td></tr>
  + *  <tr><td>m</td><td>minutes</td></tr>
  + *  <tr><td>s</td><td>seconds</td></tr>
  + *  <tr><td>S</td><td>milliseconds</td></tr>
  + * </table>
    *
    * @author Apache Ant - DateUtils
    * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
  @@ -83,29 +94,29 @@
       public static String formatISO(long millis) {
           return format(millis, "H:mm:ss.SSS");
       }
  +
       /**
  -     * <p>Get the time gap as a string, using the specified format.</p>
  -     * <table border="1">
  -     *  <tr><th>character</th><th>duration element</th></tr>
  -     *  <tr><td>y</td><td>years (aka 365 days)</td></tr>
  -     *  <tr><td>M</td><td>months (aka year/12)</td></tr>
  -     *  <tr><td>d</td><td>days</td></tr>
  -     *  <tr><td>H</td><td>hours</td></tr>
  -     *  <tr><td>m</td><td>minutes</td></tr>
  -     *  <tr><td>s</td><td>seconds</td></tr>
  -     *  <tr><td>S</td><td>milliseconds</td></tr>
  -     * </table>
  +     * <p>Get the time gap as a string, using the specified format, and padding with
zeros and 
  +     * using the default timezone.</p>
        * 
        * @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());
  -    }
  +    /**
  +     * <p>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
  +    /**
  +     * <p>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());
       }
  +    /**
  +     * <p>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


Mime
View raw message