一段有趣的代码

 1 import java.text.SimpleDateFormat;
 2 import java.util.Date;
 3 
 4 import org.junit.Test;
 5 
 6 public class IMISSYOU {
 7     @SuppressWarnings("deprecation")
 8     @Test
 9     public void OurTime(){
10         Date IMEETYOU = new Date(2016, 9, 30) ;
11         Date IMISSYOU = new Date(2017,4,10);
12         Date IMissYOU = new Date(2017,6,6);
13         
14         SimpleDateFormat sf = new SimpleDateFormat("yy-MM-dd");
15         
16         long TIMETWO = countDay(IMissYOU,IMEETYOU);
17         
18         System.out.println("IMEETYOU : "+sf.format(IMEETYOU));
19         System.out.println("IMISSYOU : "+sf.format(IMISSYOU));
20         System.out.println("IMissYOU : "+TIMETWO+" DAY");
21     }
22     
23     public long countDay(Date time1,Date time2){
24         long day=(time1.getTime()-time2.getTime())/(1000 * 60 * 60 * 24);
25         return day;
26     }
27 }

 

posted on 2017-07-06 14:34  sj_大王  阅读(327)  评论(0编辑  收藏  举报

导航