Originally posted by jman bony: I have a date of type java.util.Date and I need to read(get) the month from this date...like 0,1,2..so on. Any help appreciated.
RTFJ - Read The Fine Javadoc Javadoc for Date shows a getMonth() method, but says it's deprecated, use Calendar.get(Calendar.Month). Going to the Javadoc for Calendar, you will find two constructors, but neither takes a Date object. But there must be some way to set the time for a calendar. Scroll down the method list and you will find setTime(Date) method. With that information, you should be able to figure out this code: Calendar cal = new Calendar(); cal.setTime(myDate); int month = cal.get(Calendar.MONTH); This int value corresponds to the various contstants in Calendar: Calendar.JANUARY, Cealendar.FEBRUARY, etc. Also, if you had mucked about with the Javadoc, you might have run across a GregorianCalendar class. The Javadoc for GregorianCalendar has essentially the same code shown above. Another good source for basic "How do I..." questions is the Java FAQ at http://www.afu.com/intro.html