import java.util.*;
import java.text.*;
public class DisplayDate {
public static void main(String args[])
{
Date today;
Calendar now;
DateFormat f1,f2;
String s1,s2;
System.out.println("\n显示Date类的相关用法");
today = new Date();
System.out.println("new Date()= \t"+ today);
System.out.println("\n用DateFormat类显示各种日期格式");
//显示各种日期格式
f1 = DateFormat.getDateInstance();
s1 = f1.format(today);
System.out.println("DateFormat.getDateInstance()= \t"+s1);
f1 = DateFormat.getDateInstance(DateFormat.LONG,Locale.CHINA);
s1 = f1.format(today);
System.out.println("DateFormat.getDateInstance(DateFormat.LONG,Locale.CHINA)= \t"+ s1);
f1 = DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.CHINA);
s1 = f1.format(today);
System.out.println("DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.CHINA)= \t"+ s1);
f1 = DateFormat.getDateInstance(DateFormat.SHORT,Locale.CHINA);
s1 = f1.format(today);
System.out.println("DateFormat.getDateInstance(DateFormat.SHORT,Locale.CHINA)= \t" + s1);
System.out.println("\n用DateFormat类显示各种时间格式");
//显示各种时间格式
f1 = DateFormat.getTimeInstance();
s1 = f1.format(today);
System.out.println("DateFormat.getTimeInstance()= \t"+s1);
f1 = DateFormat.getTimeInstance(DateFormat.LONG,Locale.CHINA);
s1 = f1.format(today);
System.out.println("DateFormat.getTimeInstance(DateFormat.LONG,Locale.CHINA)= \t"+s1);
f1 = DateFormat.getTimeInstance(DateFormat.MEDIUM,Locale.CHINA);
s1 = f1.format(today);
System.out.println("DateFormat.getTimeInstance(DateFormat.MEDIUM,Locale.CHINA)= \t"+s1);
f1 = DateFormat.getTimeInstance(DateFormat.SHORT,Locale.CHINA);
s1 = f1.format(today);
System.out.println("DateFormat.getTimeInstance(DateFormat.SHORT,Locale.CHINA)= \t"+s1);
System.out.println("\n显示Calendar的相关时间用法");
now = Calendar.getInstance();
today = now.getTime();
System.out.println("Calendar.getInstance().getTime()= \t"+ today.toString());
}
}