Calendar 시간 표시하기
import java.util.Calendar;
public class CalendarTest {
public static void main(String[] args) {
Calendar now = Calendar.getInstance();
// 년도-월-일-시-분-초
int year = now.get(Calendar.YEAR);
// 5월값 저장변수 january = 0, May = 4 이다.
int month = now.get(Calendar.MONTH)+1;
int day = now.get(Calendar.DAY_OF_MONTH);
int hour = now.get(Calendar.HOUR_OF_DAY);
int min = now.get(Calendar.MINUTE);
int sec = now.get(Calendar.SECOND);
System.out.println(year+"년 "+month+"월 "+day+"일 "
+hour+"시 "+min+"분 "+sec+"초 ");
/**
* System.out.println(now);
* 모든 정보가 아래와 같이 표시된다. 시간은 1/1000초
* java.util.GregorianCalendar
* [time=1400565918062,areFieldsSet=true,
* areAllFieldsSet=true,lenient=true,
* zone=sun.util.calendar.ZoneInfo[id="Asia/Seoul",
* offset=32400000,dstSavings=0,useDaylight=false,
* transitions=14,lastRule=null],firstDayOfWeek=1,
* minimalDaysInFirstWeek=1,ERA=1,YEAR=2014,MONTH=4,
* WEEK_OF_YEAR=21,WEEK_OF_MONTH=4,DAY_OF_MONTH=20,
* DAY_OF_YEAR=140,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=3,
* AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=5,SECOND=18,
* MILLISECOND=62,ZONE_OFFSET=32400000,DST_OFFSET=0]
*/
}
}