Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to get the month from todays date

Posted on 2006-06-28
1
346 Views
Last Modified: 2010-04-01
I actually need the current month. So I was sing the following code
But the problem is that when I print the month, it gives me 5 instead of 6 which is the current month.

Any help will be greatly appreciated. When I print the whole date, it prints the right date

Date todays_date  = new Date();
      String this_month = new Integer(todays_date.getMonth()).toString();
      out.print(this_month);
0
Comment
Question by:huzefaq
1 Comment
 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
ID: 17002703
It is zero based. Month are from  0-11  The method is deprecated anyway.  You should use  Calendar.get(Calendar.MONTH)
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question