Computer_IT/JAVA

[java5] Calendar Example - 년 월 일 시 분 초

고급코드 2006. 9. 28. 09:23
반응형
 
  1. import java.util.Calendar;
  2. import java.util.Date;
  3. class CalendarExam {
  4.   public static void main(String args[]) {
  5.     Calendar calendar = Calendar.getInstance();
  6.    
  7.     System.out.print( calendar.get(Calendar.YEAR) + "년  ");
  8.    
  9.     System.out.print( calendar.get(Calendar.MONTH)+1 + "월  ");
  10.    
  11.     System.out.print( calendar.get(Calendar.DAY_OF_MONTH) + "일  ");
  12.     System.out.print( calendar.get(Calendar.HOUR) + "시 ");
  13.    
  14.     System.out.print( calendar.get(Calendar.MINUTE) + "분 ");
  15.    
  16.     System.out.print( calendar.get(Calendar.SECOND) + "초 ");
  17.    
  18.     System.out.print( calendar.get(Calendar.DAY_OF_MONTH) + "일  ");
  19.   }
  20. }
 
반응형