0

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() );
 
graduationDate.setDay(12);
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

Thanks
Sarah
x

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by peter_budo
0

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.

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.