Solved

CAlendar in java

Posted on 2003-12-10
8
287 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is JNDI datasource in spring 1 50
groovy example issue 10 87
mockito example issue 8 62
thymeleaf natural templating vs JSP 2 65
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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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 tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

948 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

22 Experts available now in Live!

Get 1:1 Help Now