SimpleDateFormat

■コード

package hello.java.text;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Locale;

public class HelloSimpleDateFormat {

static public void main(String args[]){


System.out.println( (new SimpleDateFormat("yyyy.MM.dd-HH:mm:ss")).format(new Date()).toString() );


System.out.println( (new SimpleDateFormat("yyyy-MM-dd")).format(new Date()).toString() );


// RSS <pubDate>

System.out.println( (new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US)).format(new Date()).toString() );

// Windows XP Explorer English

System.out.println( (new SimpleDateFormat("M/d/yyyy hh:mm a", Locale.US)).format(new Date()).toString() );


// Windows XP Explorer 日本語版

System.out.println( (new SimpleDateFormat("yyyy/MM/dd HH:mm", Locale.US)).format(new Date()).toString() );


// WebSphere Log

System.out.println( (new SimpleDateFormat("[yy/MM/dd HH:mm:ss:S z]")).format(new Date()).toString() );


}

}

■結果

2011.02.15-13:25:33

2011-02-15

Tue, 15 Feb 2011 13:25:33 +0900

2/15/2011 01:25 PM

2011/02/15 13:25

[11/02/15 13:25:33:140 JST]