Beispiel #1
0
        /**
         * Converts DOS time to Java time (number of milliseconds since
         * epoch).
         */
        public static long dosToJavaTime(long dosTime)
        {
            java.util.Calendar cal = java.util.Calendar.getInstance();
            // CheckStyle:MagicNumberCheck OFF - no point

            /* Basties Note: why so many method calls?
             * cal.set(java.util.Calendar.YEAR, (int) ((dosTime >> 25) & 0x7f) + 1980);
             * cal.set(java.util.Calendar.MONTH, (int) ((dosTime >> 21) & 0x0f) - 1);
             * cal.set(java.util.Calendar.DATE, (int) (dosTime >> 16) & 0x1f);
             * cal.set(java.util.Calendar.HOUR_OF_DAY, (int) (dosTime >> 11) & 0x1f);
             * cal.set(java.util.Calendar.MINUTE, (int) (dosTime >> 5) & 0x3f);
             * cal.set(java.util.Calendar.SECOND, (int) (dosTime << 1) & 0x3e);
             */
            cal.set((int)(((dosTime >> 25) & 0x7f) + 1980),
                    (int)(((dosTime >> 21) & 0x0f) - 1),
                    (int)((dosTime >> 16) & 0x1f),
                    (int)((dosTime >> 11) & 0x1f),
                    (int)((dosTime >> 5) & 0x3f),
                    (int)((dosTime << 1) & 0x3e));
            // CheckStyle:MagicNumberCheck ON
            return(cal.getTime().getTime());
        }
Beispiel #2
0
 /*
  * <p>Calls the {@link Calendar#getTimeInMillis} method.
  * Prior to JDK1.4, this method was protected and therefore
  * cannot be invoked directly.</p>
  *
  * <p>TODO: In future, this should be replaced by <code>cal.getTimeInMillis()</code>.</p>
  *
  * @param cal <code>Calendar</code> to get time in milliseconds.
  *
  * @return Milliseconds of <code>cal</code>.
  */
 private static long getCalendarTimeInMillis(java.util.Calendar cal)
 {
     return(cal.getTime().getTime());
 }