Solved

How to get the month from todays date

Posted on 2006-06-28
1
347 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
[X]
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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
web service Rest Client creation 4 99
hashcode is calculated on the basis of value object 2 127
stateless EJB with glassfish 2 73
countXY challenge 28 172
While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
This article discusses how to implement server side field validation and display customized error messages to the client.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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