/*
 * Copyright 2000-2009 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * @author max
 */
package com.intellij.util.io.zip;

import java.util.Date;

public class DosTime {
  private DosTime() {
  }

  /*
   * Converts DOS time to Java time (number of milliseconds since epoch).
   */
  public static long dosToJavaTime(long dtime) {
    Date d = new Date((int)(((dtime >> 25) & 0x7f) + 80), (int)(((dtime >> 21) & 0x0f) - 1), (int)((dtime >> 16) & 0x1f),
                      (int)((dtime >> 11) & 0x1f), (int)((dtime >> 5) & 0x3f), (int)((dtime << 1) & 0x3e));
    return d.getTime();
  }

  /*
   * Converts Java time to DOS time.
   */
  public static long javaToDosTime(long time) {
    Date d = new Date(time);
    int year = d.getYear() + 1900;
    if (year < 1980) {
      return (1 << 21) | (1 << 16);
    }
    return (year - 1980) << 25 |
           (d.getMonth() + 1) << 21 |
           d.getDate() << 16 |
           d.getHours() << 11 |
           d.getMinutes() << 5 |
           d.getSeconds() >> 1;
  }
}

@@ -669,20 +669,24 @@
 va.util.
-Date
+Calendar
 ;%0A%0Apubli
@@ -868,33 +868,66 @@
 ) %7B%0A    
-Date d = new Date
+Calendar cal = Calendar.getInstance();%0A    cal.set
 ((int)((
@@ -950,16 +950,18 @@
 0x7f) + 
+19
 80), (in
@@ -1033,26 +1033,16 @@
         
-      
-    
 (int)((d
@@ -1119,16 +1119,53 @@
 0x3e));%0A
+    cal.clear(Calendar.MILLISECOND);%0A
     retu
@@ -1171,17 +1171,19 @@
 urn 
-d
+cal
 .getTime
 ();%0A
@@ -1178,16 +1178,24 @@
 .getTime
+InMillis
 ();%0A  %7D%0A
@@ -1299,25 +1299,70 @@
     
-Date d = new Date
+Calendar cal = Calendar.getInstance();%0A    cal.setTimeInMillis
 (tim
@@ -1384,26 +1384,30 @@
 r = 
-d
+cal
 .get
-Year() + 1900
+(Calendar.YEAR)
 ;%0A  
@@ -1499,18 +1499,16 @@
 0) %3C%3C 25
- %7C
 %0A       
@@ -1515,20 +1515,33 @@
     
-(d.getMonth(
+%7C (cal.get(Calendar.MONTH
 ) + 
@@ -1548,19 +1548,18 @@
 1) %3C%3C 21
- %7C
 %0A
+ 
         
@@ -1564,28 +1564,46 @@
     
- d.getDate(
+%7C cal.get(Calendar.DAY_OF_MONTH
 ) %3C%3C 16
- %7C
 %0A   
@@ -1614,28 +1614,45 @@
     
-d.getHours(
+%7C cal.get(Calendar.HOUR_OF_DAY
 ) %3C%3C 11
- %7C
 %0A   
@@ -1663,29 +1663,39 @@
     
-d.getMinutes(
+%7C cal.get(Calendar.MINUTE
 ) %3C%3C 5
- %7C
 %0A   
@@ -1706,21 +1706,33 @@
     
-d.getSeconds(
+%7C cal.get(Calendar.SECOND
 ) %3E%3E

remove usage of deprecated API