Date Display Problem in Java

zhaozj2021-02-08  353

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

转载请注明原文地址:https://www.9cbs.com/read-915.html

New Post(0)