Import java. util .*;
Import java. Text .*;
Public class styledemo {
Public static void main (string [] ARGs ){
Date Now = new date ();
Dateformat df = dateformat. getdateinstance ();
Dateformat DF1 = dateformat. getdateinstance (dateformat. Short );
Dateformat df2 = dateformat. getdateinstance (dateformat. Medium );
Dateformat df3 = dateformat. getdateinstance (dateformat. Long );
Dateformat df4 = dateformat. getdateinstance (dateformat. Full );
String S = DF. Format (now );
String S1 = df1.format (now );
String S2 = df2.format (now );
String S3 = df3.format (now );
String S4 = df4.format (now );
System. Out. println ("(default) today is" + S );
System. Out. println ("(short) today is" + S1 );
System. Out. println ("(medium) today is" + S2 );
System. Out. println ("(long) today is" + S3 );
System. Out. println ("(full) today is" + S4 );
}
}
That program output the following:
(Default) Today is Nov 8, 2000
(Short) Today is 11/8/00
(Medium) Today is Nov 8, 2000
(Long) Today is November 8, 2000
(Full) Today is Wednesday, November 8, 2000