aijava

welcome to my online log ! open java new world! Taste java charm........
posts - 1, comments - 4, trackbacks - 0, articles - 42
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

java基础学习4(java.util.Calendar)

Posted on 2006-11-05 17:52 阅读(144) 评论(0)  编辑  收藏 所属分类: java基础学习系列
import  java.util.Calendar;

public class  MainClass  {
   public static  void  main ( String args []) {
     String months []  "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" ,
         "Sep" "Oct" "Nov" "Dec"  } ;

     Calendar calendar = Calendar.getInstance () ;

     System.out.print ( "Date: " ) ;
     System.out.print ( months [ calendar.get ( Calendar.MONTH )]) ;
     System.out.print ( " "  + calendar.get ( Calendar.DATE " " ) ;
     System.out.println ( calendar.get ( Calendar.YEAR )) ;

     System.out.print ( "Time: " ) ;
     System.out.print ( calendar.get ( Calendar.HOUR ":" ) ;
     System.out.print ( calendar.get ( Calendar.MINUTE ":" ) ;
     System.out.println ( calendar.get ( Calendar.SECOND )) ;

     calendar.set ( Calendar.HOUR,  10 ) ;
     calendar.set ( Calendar.MINUTE,  29 ) ;
     calendar.set ( Calendar.SECOND,  22 ) ;

     System.out.print ( "Updated time: " ) ;
     System.out.print ( calendar.get ( Calendar.HOUR ":" ) ;
     System.out.print ( calendar.get ( Calendar.MINUTE ":" ) ;
     System.out.println ( calendar.get ( Calendar.SECOND )) ;
   }
}

http://freehost13.websamba.com