Solved

CAlendar in java

Posted on 2003-12-10
8
294 Views
Last Modified: 2010-03-31
HI
Calendar c = Calendar.getInstance();
System.out.println("month and year is " + c.MONTH+ "      "+c.YEAR );

gives me
month and year is 2      1

y?

Thx


       
0
Comment
Question by:applekanna
[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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 30 total points
ID: 9917148
c.get(Calendar.YEAR);
c.get(Calendar.MONTH);
0
 
LVL 15

Assisted Solution

by:jimmack
jimmack earned 20 total points
ID: 9917151
You're displaying the constants from the class, not the values contained in the object "c".

0
 
LVL 3

Author Comment

by:applekanna
ID: 9917153
I want toget 11 and 2003
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 15

Expert Comment

by:jimmack
ID: 9917157
Watch out for the strange thing about months.  They're numbered 0 .. 11 (not 1 .. 12) ;-)
0
 
LVL 92

Expert Comment

by:objects
ID: 9917177
> I want toget 11 and 2003

System.out.println("month and year is " + (c.get(Calendar.MONTH)+1)+ "      "+c.get(Calendar.YEAR) );
0
 
LVL 3

Author Comment

by:applekanna
ID: 9917182
Thx for you qwik help
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9917188
;-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9917189
8-)
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

615 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