Solved

CAlendar in java

Posted on 2003-12-10
8
292 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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

734 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