import java.text.SimpleDateFormat;
import java.util.Calendar;
public class sysdt {
public static void main(String[] args) {
// パターン文字
String format[] = {
"yyyyMMdd",
"yyyy/MM/dd",
"w",//
"W",//
"d",//
"D",//
"G",// 西暦
"F",// 第何月曜日か
"E",// 曜日
"a",// 午前 or 午後
"yyyy年MM月dd日 KK:mm:ss SSS",
"yyyy/MM/dd HH:mm:ss SSS",
"yyyy/MM/dd kk:mm:ss SSS",
"yyyy/MM/dd hh:mm:ss SSS",
"yyyy/MM/dd ak:mm:ss SSS",
"yyyy/MM/dd ah:mm:ss SSS",
"yyyy/MM/dd K:m:s SSS",
"yyyy/MM/dd H:m:s SSS"
};
for(int i = 0;i<format.length ;i++){
Calendar calendar = Calendar.getInstance();
System.out.println(
new SimpleDateFormat(format[i]).format(calendar.getTime()));
}
}
}
実行結果は以下のようになります。
20070126
2007/01/26
4
4
26
26
西暦
4
金
午後
2007年01月26日 07:07:00 265
2007/01/26 19:07:00 265
2007/01/26 19:07:00 265
2007/01/26 07:07:00 265
2007/01/26 午後19:07:00 265
2007/01/26 午後7:07:00 281
2007/01/26 7:7:0 281
2007/01/26 19:7:0 281