Hi All,

I am a total java novice and i am having a real problem running the following code:

import java.util.*;
public class Methods
public static void main( String [] args)
Date independenceDay = new Date ( 7, 4, 1776 );
int independenceMonth = independenceDay.getMonth();
System.out.println("Independence day is in month " + independenceMonth);
Date graduationDate = new Date (5, 15, 2008);
System.out.println("The current day for graduation is " + graduationDate.getDay() );
System.out.println( "The revised day for graduation is " + graduationDate.getDay() );

This is actually from a book i am working through and if it isn't working i was wondering if there was something wrong with the code or my pc.

The error message reads:

1 error found:
File: C:\Documents and Settings\Steven\Desktop\Methods.java [line: 16]
Error: cannot find symbol
symbol : method setDay(int)
location: class java.util.Date

Please help


First of all, many of the methods in the Date class is depreciated. They are still implemented, but the Calendar class fills the same niche better.

As for your actual problem, you'd be after the setDate(int) method.

Check you the Java API if you haven't already.

There is no setDay() method in the Date Class, this mean your book must be old and you will get more similar problems...
Follow the link which David give it to you, in packages find java.util, then bellow find Date and read trough
I use now Deitel&Deitel JAVA How to Program 6th edition

This article has been dead for over six months. Start a new discussion instead.