자바에서 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 마크가 발생한다.
처음에는 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 마크가 발생한다.




댓글을 달아 주세요
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