This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

get the current month in 'mon' format  RSS feed

 
nelson christos
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i needed to know which is a better way of getting the current month in the 'mon' format.

1) new Date().toString().substring(4,7).toLowerCase()

2)String a[]={"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"};
int index=Calendar.getInstance().get(Calendar.MONTH);
month=a[index];
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi nelson. Do you think this question has something to do with Servlets ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
151
IntelliJ IDE Java jQuery Mac Mac OS X
 
vijaya bharath
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
you can do this using java.util.SimpleDateFormat class. Use the SimpleDateFormat constructor to specify the format you want to print out the date and use the format function on that SimpleDateFormat object by passing your input date object.You will get the date in the format specified in the constructor.Usually you give the Format as YYYY if you want to print year in 4 digits.Try that.Once you get the answer please let us know. If you have any doubts you cna ask.Hope this is helpful to you.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!