Solved

CAlendar in java

Posted on 2003-12-10
8
288 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
custom annotations 9 38
javap bin 2 34
hibernate example for saving data 19 37
jsp login check 12 27
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

815 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now