Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a problem with Date class

 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also check this code
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic