Hi, I want to get all months of a year in JAN,FEB, etc. format and add those in an array dynamically. How can I do that using Java? Can anyone please help me by sending a piece of code?
Note that the JavaRanch is not a code producing machine, i.e. it is not meant as a place where you can have other people do your work for you without putting any effort into it yourself.
So, what have you tried yourself so far?
Some classes that would be useful for this are java.util.Calendar and java.text.SimpleDateFormat. Look these up in the API documentation and write some code yourself. If you have trouble with it, post your code here and we can point you in the right direction.
You can use a combination of java.text.SimpleDateFormat and java.util.Calendar derived classes. A SimpleDateFormat instance implicitly has a Calendar instance attached that gives the information about how many months in a year (which BTW may vary by calendar and by year). There is also an implicitly attached Locale that maps month numbers to names.
If you are building a highly internationalized application and cannot rely on using the typical GregorianCalendar and cannot rely on the default Locale taking care of all this for you (i.e. you are building a web app accessible across many countries using different calendars) then you will have to become very familiar with Calendar, TimeZone and Locale classes.
OTOH, if this is a class project start with SimpleDateFormat get the calendar from that and then get the month start and end index (again which may vary by the current year).
BTW, even if you do write your code as internationalized as possible it still won't always be correct 'cause some calendars rely on local observations of celestial events to mark time.