Question about Calendar
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Yamini_Edupuganti
Posted On:   Monday, October 13, 2003 09:32 AM


I am trying to find out the current month and year and I am not able to find a simple way to do this.


Please help.

Re: Question about Calendar

Posted By:   Joost_Schouten  
Posted On:   Monday, October 13, 2003 11:11 AM


java.util.GregorianCalendar cal = new java.util.GregorianCalendar();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
int date = cal.get(Calendar.DATE);

Note that the GregorianCalendar you create will use the time, date and time zone your computer is using, unless you sent it's constructor the appropriate variables. Check out the API for how to use it more extensively.


Also note that the month integer of January is 0 and not 1. So December is 11 and not 12.


Cheers,

Joost

About | Sitemap | Contact