Solved

CAlendar in java

Posted on 2003-12-10
8
286 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoreUp challenge 14 48
Fibonacci challenge 11 84
bunnyEars2 challenge 6 68
Python Assistance 7 36
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

757 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

19 Experts available now in Live!

Get 1:1 Help Now