New topics: Your Pet, IOU, Baby IQ, The Poisons, Birther II, Games, Future Power

Welcome to the Tech Space!

Wiki Articles

Skip to end of metadata
Go to start of metadata
		// Display today's date using a default format for the current locale
		DateFormat defaultDate = DateFormat.getDateInstance();
		System.out.println(defaultDate.format(new Date()));
		
		// Display the current time using a short time format for the current locale
		DateFormat shortTime = DateFormat.getTimeInstance(DateFormat.SHORT);
		System.out.println(shortTime.format(new Date()));

		 // Hours and minutes using 12-hour clock
		 Calendar c = Calendar.getInstance();
		 c.setTime(d);
		 String s = String.format("%tl:%tM %tp", now, d, c);  // "3:12 pm"		
		
		
		// current hours and minutes
		 long now = System.currentTimeMillis();
		 String sTime = String.format("%tR", now);         // "15:12"

		 // Current month/day/year
		 Date d = new Date(now);
		 String sDate = String.format("%tD", d);                  // "07/13/04"
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.