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 GregorianCalendar object 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 "GregorianCalendar object" Watch "GregorianCalendar object" New topic
Author

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

-----------------
Sainudheen
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.


Mani
Quaerendo Invenietis
Eric Sexton
Ranch Hand

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

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: GregorianCalendar object
 
Similar Threads
Comparing dates...
Is it possible to generate a random date with gregorian calendar?
GregorianCalendar issues - how to display?
Adjusting GregorianCalendar to reflect a specific TimeZone
JSpinner Problem