1import java.util.*;
 2
 3public class CalendarDemo
 4{
 5 public static void main(String[] args)
 6 {
 7  Calendar instcalendar=Calendar.getInstance();
 8  
 9         instcalendar.setTime(new Date());
10         
11         String cyear=String.valueOf(instcalendar.get(Calendar.YEAR));
12         String cmonth=String.valueOf(instcalendar.get(Calendar.MONTH)+1);
13         String cdate=String.valueOf(instcalendar.get(Calendar.DAY_OF_MONTH));
14         String cday=String.valueOf(instcalendar.get(Calendar.DAY_OF_WEEK)-1);
15         
16         int chour=instcalendar.get(Calendar.HOUR_OF_DAY);
17         int cminute=instcalendar.get(Calendar.MINUTE);
18         int csecond=instcalendar.get(Calendar.SECOND);
19         
20         System.out.println("现在的时间是:");
21         System.out.println(""+cyear+""+cmonth+""+cdate+""+"星期"+cday);
22         System.out.println(""+chour+""+cminute+""+csecond+"");
23         
24         instcalendar.set(2004,9,1);
25         long ctime2004=instcalendar.getTimeInMillis();
26         instcalendar.set(2005,9,1);
27         long ctime2005=instcalendar.getTimeInMillis();
28         long interdays=(ctime2005-ctime2004)/(1000*60*60*24);
29         
30         System.out.println("2004年10月1日和2005年10月1日相隔"+interdays+"");
31 }

32}

33