View Single Post
  #1 (permalink)  
Old 10-04-2007, 11:26 PM
JavaBean's Avatar
JavaBean JavaBean is offline
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
How to use Calendar class
This tip will show the use of Calendar class and print the current date and time on the console.

Code:
import java.util.Calendar; public class CalendarExp { public static void main(String[] args) { Calendar c = Calendar.getInstance(); System.out.println(""); System.out.println("YEAR : " + c.get(Calendar.YEAR)); System.out.println("MONTH : " + c.get(Calendar.MONTH)); System.out.println("DAY_OF_MONTH : " + c.get(Calendar.DAY_OF_MONTH)); System.out.println("HOUR : " + c.get(Calendar.HOUR)); System.out.println("MINUTE: " + c.get(Calendar.MINUTE)); System.out.println("SECOND: " + c.get(Calendar.SECOND)); } }
Reply With Quote
Sponsored Links