You're suffering from the same problem as this thread - you use a 1-based month numbering whereas Calendar uses a 0-based month numbering.
But Greg is right. Calendar has a method called setTime which takes a Date object. Also, Calendar.getInstance() already returns a Calendar instance for the current moment, so in this case (where the Date is also the current moment) it's not necessary to call setTime.
One addition to Greg's post:
Greg Brannon wrote:convert int DAY_OF_WEEK to name of the day
DateFormatSymbols can be used for that. The String you're interested in is indexed using the return values of Calendar.get so no need for translations there.
Thanks, I learned something, but I have a follow up for clarification.
Let's say the Calendar object is today, then today.get( Calendar.DAY_OF_WEEK ) returns an integer, 1 through 7, corresponding to SUNDAY through SATURDAY. My point was, however it's done, the integer returned by Calendar's get() method has to be converted from an integer to the name of the day. As you pointed out, that conversion can be done using DateFormatSymbols.
Is that what you meant, or am I missing something more fundamental?
Nope, that's about it. Please note that DateFormatSymbols supports I18N - different locale means different labels. You'll be able to print the weekday names in English, German, French, etc by just changing the Locale object to use.
Joined: Oct 24, 2010
Joined: Jan 19, 2010
Thanks so much all .....
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: is this not suppose to give me date of the week?