Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • Last Modified:

How to get the month from todays date

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
huzefaq
Asked:
huzefaq
1 Solution
 
rrzCommented:
It is zero based. Month are from  0-11  The method is deprecated anyway.  You should use  Calendar.get(Calendar.MONTH)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now