Mega Code Archive

 
Categories / Java / Development Class
 

System out printf(The DATE is %trn, new Date() )

import java.util.Date; import java.util.Locale; public class PrintfExamples {   public static void main(String[] args) {     System.out.printf("The DATE is %tD\n", new Date() );     System.out.printf("The DATE is %tF\n", new Date() );     System.out.printf("The DATE is %tr\n", new Date() );     System.out.printf("The DATE is %tR\n", new Date());     System.out.printf("The DATE is %tT\n", new Date());   } } /* The DATE is 10/31/08 The DATE is 2008-10-31 The DATE is 04:29:46 PM The DATE is 16:29 The DATE is 16:29:46  */