This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes GregorianCalendar object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "GregorianCalendar object" Watch "GregorianCalendar object" New topic

GregorianCalendar object

Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
If I have a GregorianCalendar object, and a method to get the date:

Now I want to display a String representation of the name of the month. So if I got back a "0", then I want to display 'January'. Obviously, I don't want a huge "if if if" statement. Thanks in advance!
Sainudheen Mydeen
Ranch Hand

Joined: Aug 18, 2003
Posts: 218
How about this

Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
I don't know whether any build-in methods / variable are available to do this, but in case if there aren't any, you can try this way.

Quaerendo Invenietis
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
Yeah. That will work for me. Thanks.
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
Aside from the (in this case preferable) method of using an array as shown above, here's another way that will work, using java.text.SimpleDateFormat:

[ September 30, 2003: Message edited by: Jason Menard ]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: GregorianCalendar object
It's not a secret anymore!