commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grobme...@apache.org
Subject svn commit: r763557 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
Date Thu, 09 Apr 2009 08:29:47 GMT
Author: grobmeier
Date: Thu Apr  9 08:29:47 2009
New Revision: 763557

URL: http://svn.apache.org/viewvc?rev=763557&view=rev
Log:
replaced deprecated method calls

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java?rev=763557&r1=763556&r2=763557&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
Thu Apr  9 08:29:47 2009
@@ -49,22 +49,21 @@
      * @return the date as a byte array
      */
     public static byte[] toDosTime(long t) {
-        Date time = new Date(t);
-        // CheckStyle:MagicNumberCheck OFF - I do not think that using constants
-        //                                   here will improve the readablity
-        int year = time.getYear() + 1900;
+        Calendar c = Calendar.getInstance();
+        c.setTimeInMillis(t);
+
+        int year = c.get(Calendar.YEAR);
         if (year < 1980) {
             return (byte[]) DOS_TIME_MIN.clone(); // stop callers from changing the array
         }
-        int month = time.getMonth() + 1;
+        int month = c.get(Calendar.MONTH) + 1;
         long value =  ((year - 1980) << 25)
             |         (month << 21)
-            |         (time.getDate() << 16)
-            |         (time.getHours() << 11)
-            |         (time.getMinutes() << 5)
-            |         (time.getSeconds() >> 1);
+            |         (c.get(Calendar.DAY_OF_MONTH) << 16)
+            |         (c.get(Calendar.HOUR_OF_DAY) << 11)
+            |         (c.get(Calendar.MINUTE) << 5)
+            |         (c.get(Calendar.SECOND) >> 1);
         return ZipLong.getBytes(value);
-        // CheckStyle:MagicNumberCheck ON
     }
 
     /**



Mime
View raw message