File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get month name

 
ram gaurav
Ranch Hand
Posts: 208
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI

Like i have an integer value 1.

Now i want to get month which come at place of 1, as months started from 0 , like 0 means Janurary, so 1 means February.

Is there any method where i can pass the integer value and get back the month name.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. You'll have to do this translation yourself. Calendars only hold the value of the time, how it is displayed is seperate. Have a look at java.text.SimpleDateFormat for a starter as to how to apply a format to your date.
[ January 24, 2007: Message edited by: Paul Sturrock ]
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do it simply like this:

- Create an array of strings containing the names of the months.
- Use the integer as an index in the array to lookup the name of the month.
 
ram gaurav
Ranch Hand
Posts: 208
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.
 
Ajay Singh
Ranch Hand
Posts: 182
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use SimpleDateFormat to get the string

 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
another option

System.out.println(new java.text.DateFormatSymbols().getMonths()[1]);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic