자바에서 2010.01.08 과 같이 표현할 일이 생겼다.

처음에는 Calendar 객체를 통해서 구하려했다.

Calendar clendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;    // month는 0부터 시작함
int day = calendar.get(Calendar.DAY_OF_MONTH);

System.out.printf("%4d.%02d.%02d", year, month, day);


이렇게 C언어에서 쓰던 표현식을 이용한 출력을 통해 나타낼 수 있다.

근데,

더 간단한 방법을 찾아냈다.

SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd", Locale.KOREA);
System.out.println(sdf.format(new Date());

이래줘야 자바지...^^

뒤에 Locale은 옵션인 듯 한데, 안 써주니까는 warning 마크가 발생한다.
2010/01/08 15:58 2010/01/08 15:58
Posted by freeism

트랙백 주소 :: http://www.freeism.co.kr/tc/trackback/648

댓글을 달아 주세요

  1. vibram fivefinger shoes 2010/07/15 15:29  댓글주소  수정/삭제  댓글쓰기

    The landlord, I found the information is very well.It provide some chargeable to client's choice. <a href="http://www.usa-basketball-shoes.com/Nike-Zoom-Blur.html" >Nike Zoom Blur</a> Self travel, decide our own travel, this travel more wonderful.We can buy something while travelling.Iprovidesome websites for you that is wonderful.suchas

이전페이지 1 ... 12 13 14 15 16 17 18 19 20 ... 179 다음페이지
사이드바 열기