commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/time DateUtils.java DurationFormatUtils.java
Date Tue, 23 Dec 2003 03:54:14 GMT
psteitz     2003/12/22 19:54:14

  Modified:    lang/src/java/org/apache/commons/lang/time DateUtils.java
                        DurationFormatUtils.java
  Log:
  Deprecated integer MILLIS_IN_* constants and replaced with long versions
  named MILLIS_PER_*.
  PR # 25627
  Reported by Nikolay Metchev
  
  Revision  Changes    Path
  1.17      +36 -6     jakarta-commons/lang/src/java/org/apache/commons/lang/time/DateUtils.java
  
  Index: DateUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/time/DateUtils.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DateUtils.java	18 Aug 2003 21:52:39 -0000	1.16
  +++ DateUtils.java	23 Dec 2003 03:54:14 -0000	1.17
  @@ -68,6 +68,7 @@
    * @author Stephen Colebourne
    * @author Janek Bogucki
    * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
  + * @author Phil Steitz
    * @since 2.0
    * @version $Id$
    */
  @@ -80,19 +81,19 @@
       /**
        * Number of milliseconds in a standard second.
        */
  -    public static final int MILLIS_IN_SECOND = 1000;
  +    public static final long MILLIS_PER_SECOND = 1000;
       /**
        * Number of milliseconds in a standard minute.
        */
  -    public static final int MILLIS_IN_MINUTE = 60 * 1000;
  +    public static final long MILLIS_PER_MINUTE = 60 * 1000;
       /**
        * Number of milliseconds in a standard hour.
        */
  -    public static final int MILLIS_IN_HOUR = 60 * 60 * 1000;
  +    public static final long MILLIS_PER_HOUR = 60 * 60 * 1000;
       /**
        * Number of milliseconds in a standard day.
        */
  -    public static final int MILLIS_IN_DAY = 24 * 60 * 60 * 1000;
  +    public static final long MILLIS_PER_DAY = 24 * 60 * 60 * 1000;
   
       /**
        * This is half a month, so this represents whether a date is in the top
  @@ -700,5 +701,34 @@
               throw new UnsupportedOperationException();
           }
       }
  -
  +    
  +    //------------------------------------------------------------------------- 
  +    // Deprecated int constants
  +    // TODO: Remove in 3.0
  +    
  +    /**
  +     * Number of milliseconds in a standard second.
  +     * 
  +     * @deprecated Use MILLIS_PER_SECOND. This will be removed in Commons Lang 3.0.
  +     */
  +    public static final int MILLIS_IN_SECOND = 1000;
  +    /**
  +     * Number of milliseconds in a standard minute.
  +     * 
  +     * @deprecated Use MILLIS_PER_MINUTE. This will be removed in Commons Lang 3.0.
  +     */
  +    public static final int MILLIS_IN_MINUTE = 60 * 1000;
  +    /**
  +     * Number of milliseconds in a standard hour.
  +     * 
  +     * @deprecated Use MILLIS_PER_HOUR. This will be removed in Commons Lang 3.0.
  +     */
  +    public static final int MILLIS_IN_HOUR = 60 * 60 * 1000;
  +    /**
  +     * Number of milliseconds in a standard day.
  +     * 
  +     * @deprecated Use MILLIS_PER_DAY. This will be removed in Commons Lang 3.0.
  +     */
  +    public static final int MILLIS_IN_DAY = 24 * 60 * 60 * 1000;
  +    
   }
  
  
  
  1.8       +11 -11    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DurationFormatUtils.java	20 Dec 2003 22:19:21 -0000	1.7
  +++ DurationFormatUtils.java	23 Dec 2003 03:54:14 -0000	1.8
  @@ -106,12 +106,12 @@
        */
       public static String formatISO(long millis) {
           int hours, minutes, seconds, milliseconds;
  -        hours = (int) (millis / DateUtils.MILLIS_IN_HOUR);
  -        millis = millis - (hours * DateUtils.MILLIS_IN_HOUR);
  -        minutes = (int) (millis / DateUtils.MILLIS_IN_MINUTE);
  -        millis = millis - (minutes * DateUtils.MILLIS_IN_MINUTE);
  -        seconds = (int) (millis / DateUtils.MILLIS_IN_SECOND);
  -        millis = millis - (seconds * DateUtils.MILLIS_IN_SECOND);
  +        hours = (int) (millis / DateUtils.MILLIS_PER_HOUR);
  +        millis = millis - (hours * DateUtils.MILLIS_PER_HOUR);
  +        minutes = (int) (millis / DateUtils.MILLIS_PER_MINUTE);
  +        millis = millis - (minutes * DateUtils.MILLIS_PER_MINUTE);
  +        seconds = (int) (millis / DateUtils.MILLIS_PER_SECOND);
  +        millis = millis - (seconds * DateUtils.MILLIS_PER_SECOND);
           milliseconds = (int) millis;
   
           StringBuffer buf = new StringBuffer(32);
  @@ -145,10 +145,10 @@
           boolean suppressLeadingZeroElements,
           boolean suppressTrailingZeroElements) {
           long[] values = new long[4];
  -        values[0] = millis / DateUtils.MILLIS_IN_DAY;
  -        values[1] = (millis / DateUtils.MILLIS_IN_HOUR) % 24;
  -        values[2] = (millis / DateUtils.MILLIS_IN_MINUTE) % 60;
  -        values[3] = (millis / DateUtils.MILLIS_IN_SECOND) % 60;
  +        values[0] = millis / DateUtils.MILLIS_PER_DAY;
  +        values[1] = (millis / DateUtils.MILLIS_PER_HOUR) % 24;
  +        values[2] = (millis / DateUtils.MILLIS_PER_MINUTE) % 60;
  +        values[3] = (millis / DateUtils.MILLIS_PER_SECOND) % 60;
           String[] fieldsOne = { " day ", " hour ", " minute ", " second" };
           String[] fieldsPlural = { " days ", " hours ", " minutes ", " seconds" };
   
  
  
  

---------------------------------------------------------------------
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