This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes a problem with Date class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "a problem with Date class" Watch "a problem with Date class" New topic
Author

a problem with Date class

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
i am executing this code

import java.util.Date;


public class Test
{
public static void main(String ars[])

{

System.out.println(new Date().getYear());


}

}

I am getting the output as 105 instead of 2005


is there any error in java ?


cinux


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Please have a look at java docs..

This is from java docs.

public int getYear()Deprecated. As of JDK version 1.1, replaced by Calendar.get(Calendar.YEAR) - 1900.

Returns a value that is the result of subtracting 1900 from the year that contains or begins with the instant in time represented by this Date object, as interpreted in the local time zone.

[ December 30, 2005: Message edited by: Srinivasa Raghavan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Also check this code
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Read the java docs when you're having a problem with a method in the API?!
The illuminati have leaked a secret meant only for true believers!
This is a banner day for the advanced forum


There is no emoticon for what I am feeling!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: a problem with Date class
 
Similar Threads
What is the output and Why
Day light saving
HELP needed on DATE
jsp/tomcat undefined type error
Superclass methods not able to acces