import java.util.*;
public class CalendarTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Calendar calendar = Calendar.getInstance();
Locale locale = null;
System.out.println(String.format(
"시간 -> %tH %tI %tk %tM %tS %tL %tN %tp %tz %tZ %ts %tQ",
new Date(), new Date(), new Date(), new Date(), new Date(),
new Date(), new Date(), new Date(), new Date(), new Date(),
new Date(), new Date()));
System.out.println(String.format(
"시간 -> %TH %TI %Tk %TM %TS %TL %TN %Tp %Tz %TZ %Ts %TQ",
new Date(), new Date(), new Date(), new Date(), new Date(),
new Date(), new Date(), new Date(), new Date(), new Date(),
new Date(), new Date()));
System.out.println(String.format(
"일자 -> %tB %tb %th %tA %ta %tC %tY %ty %tj %tm %td %te ",
new Date(), new Date(), new Date(), new Date(), new Date(),
new Date(), new Date(), new Date(), new Date(), new Date(),
new Date(), new Date()));
System.out.println(String.format("일자/시각 -> %tR %tT %tr %tD %tF %tc",
new Date(), new Date(), new Date(), new Date(), new Date(),
new Date()));
/* yyyy-MM-dd hh-mm-ss */
System.out.println(String.format("%tF %tT", calendar, calendar));
System.out.println(String.format("%1$tF %1$tT", calendar));
/* yyyy.MM.dd hh-mm-ss */
System.out.println(String.format("%tY.%tm.%td %tT", calendar, calendar, calendar, calendar));
System.out.println(String.format("%1$tY.%1$tm.%1$td %1$tp %1$tT",calendar));
locale = Locale.US;
System.out.println(String.format(locale,"%1$tY.%1$tm.%1$td %1$tp %1$tT", calendar));
}
}
결과
시간 -> 12 12 12 14 27 344 344000000 오후 +0900 KST 1275275667 1275275667344
시간 -> 12 12 12 14 27 364 364000000 오후 +0900 KST 1275275667 1275275667364
일자 -> 5월 5월 5월 월요일 월 20 2010 10 151 05 31 31
일자/시각 -> 12:14 12:14:27 12:14:27 오후 05/31/10 2010-05-31 월 5월 31 12:14:27 KST 2010
2010-05-31 12:14:27
2010-05-31 12:14:27
2010.05.31 12:14:27
2010.05.31 오후 12:14:27
2010.05.31 pm 12:14:27
'프로그래밍 > java' 카테고리의 다른 글
자바로 MAC Address 알아오기 (0) | 2011.01.14 |
---|---|
jxl 엑셀 수정 예제 (0) | 2010.06.25 |
자바 SimpleDateFormat 정리 - 시간 및 날짜(Date) (0) | 2010.05.31 |
자바 파일 인코딩 알아내기 (0) | 2010.04.15 |
자바 인코딩 관련 (0) | 2010.04.15 |