This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Date -problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date -problem" Watch "Date -problem" New topic
Author

Date -problem

Bala Krishniah
Ranch Hand

Joined: Dec 14, 2000
Posts: 81
I have a method which returns a Date object.
I have to get this date object, get the corresponding month.
How to do this.
Date's class getMonth() method is depricated. The document says use Calender class. But using date object, how do I use Calender class? Please help!
Michael Hildner
Ranch Hand

Joined: Oct 13, 2000
Posts: 297
Here's some sample code, note that the month returned is zero-based.
DS
Greenhorn

Joined: Jan 22, 2001
Posts: 1
If you are using the current date in your program,
calendar.get (Calendar.MONTH) works if u have initialized calendar object.Else use the Date from the method which returns the date.In your other method to calculate the month,get the date object and first use String tokenizer and get the two digits of the month,then in your month method use comparisions for the digits to months and return the month to your main class and print it.I think that should help you.
------------------
DS


DS
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date -problem
 
Similar Threads
compare two dates thru Calendar
Date
Date - problem
Need to get a Day from Date
Downcasting And Upcasting