「Java」java.text.SimpleDateFormatクラスの使い方

Javaコード:
import java.util.Date;
import java.text.DateFormat;

public class DateDemo{
public static void main(String []args){
Date d = new Date();
String s;

System.out.println(d);

System.out.println(“******************************************”);

/** getDateInstance() */
s = DateFormat.getDateInstance().format(d);
System.out.println(s);

s = DateFormat.getDateInstance(DateFormat.DEFAULT).format(d);
System.out.println(s);

s = DateFormat.getDateInstance(DateFormat.FULL).format(d);
System.out.println(s);

s = DateFormat.getDateInstance(DateFormat.MEDIUM).format(d);
System.out.println(s);

s = DateFormat.getDateInstance(DateFormat.SHORT).format(d);
System.out.println(s);

 

java.text.DateFormat fmt = new java.text.SimpleDateFormat(“yyyy-MM-dd hh:mm:ss”);
s = fmt.format(new Date());
System.out.println(s);

System.out.println((new java.text.SimpleDateFormat(“yyyy-MM-dd hh:mm:ss”)).format(new Date()));

java.text.DateFormat cft = new java.text.SimpleDateFormat(“yyyyMMddhhmmss”);
s = cft.format(new Date());
System.out.println(s);
}
}