Mega Code Archive

 
Categories / Java Tutorial / Development
 

Display complete time and date information

import java.util.Calendar; import java.util.Formatter; public class Main {   public static void main(String[] argv) throws Exception {     Formatter fmt = new Formatter();     Calendar cal = Calendar.getInstance();     fmt.format("Time and date in lowercase: %tc\n", cal);     fmt.format("Time and date in uppercase: %Tc\n", cal);     System.out.println(fmt);   } } /* Time and date in lowercase: Mon Mar 09 15:03:26 PDT 2009 Time and date in uppercase: MON MAR 09 15:03:26 PDT 2009 */