Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to get month name by using Calendar class

807606May 28 2007 — edited May 28 2007
hi all

i am writing the program using Calendar Class. So i wrote following code

Date createddate =new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(createddate);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
month=month+1;

String result=month+" "+year

Output:

5 2007

But i want to print the month name like "May","January" instead of month number like 5,6 etc.
so is there any method in the Calendar class which will give me the name of the month.Or is there any alternative way to achive the same?[b]

Thanks in advance

Regards
andy
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 25 2007
Added on May 28 2007
3 comments
386 views