Calendar类
import java. util. Calendar;
import java. util. Date;
public class Demo01Canlendar {
public static void main ( String[ ] args) {
demo04 ( ) ;
}
public static void demo ( ) {
Calendar c= Calendar. getInstance ( ) ;
int year= c. get ( Calendar. YEAR) ;
System. out. println ( year) ;
int month= c. get ( Calendar. MONTH) ;
System. out. println ( month) ;
int date= c. get ( Calendar. DAY_OF_MONTH) ;
System. out. println ( date) ;
}
public static void demo01 ( ) {
Calendar c= Calendar. getInstance ( ) ;
c. set ( Calendar. YEAR, 9999 ) ;
c. set ( Calendar. MONTH, 9 ) ;
c. set ( Calendar. DAY_OF_MONTH, 9 ) ;
int year= c. get ( Calendar. YEAR) ;
System. out. println ( year) ;
int month= c. get ( Calendar. MONTH) ;
System. out. println ( month) ;
int date= c. get ( Calendar. DAY_OF_MONTH) ;
System. out. println ( date) ;
}
private static void demo02 ( ) {
Calendar c= Calendar. getInstance ( ) ;
c. add ( Calendar. YEAR, 8 ) ;
c. add ( Calendar. MONTH, 8 ) ;
c. add ( Calendar. DAY_OF_MONTH, 8 ) ;
int year= c. get ( Calendar. YEAR) ;
System. out. println ( year) ;
int month= c. get ( Calendar. MONTH) ;
System. out. println ( month) ;
int date= c. get ( Calendar. DAY_OF_MONTH) ;
System. out. println ( date) ;
}
private static void demo04 ( ) {
Calendar c= Calendar. getInstance ( ) ;
System. out. println ( c) ;
Date date= c. getTime ( ) ;
System. out. println ( date) ;
}
}