943,931 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1798
  • Java RSS
Oct 26th, 2006
0

Help Java novice

Expand Post »
Hi All,

I am a total java novice and i am having a real problem running the following code:
java Syntax (Toggle Plain Text)
  1. import java.util.*;
  2.  
  3. public class Methods
  4. {
  5. public static void main( String [] args)
  6. {
  7.  
  8. Date independenceDay = new Date ( 7, 4, 1776 );
  9. int independenceMonth = independenceDay.getMonth();
  10. System.out.println("Independence day is in month " + independenceMonth);
  11.  
  12.  
  13. Date graduationDate = new Date (5, 15, 2008);
  14. System.out.println("The current day for graduation is " + graduationDate.getDay() );
  15.  
  16. graduationDate.setDay(12);
  17. System.out.println( "The revised day for graduation is " + graduationDate.getDay() );
  18. }
  19. }
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
Last edited by cscgal; Oct 27th, 2006 at 12:51 pm. Reason: [code=java] [/code] tags added
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sarahavickers is offline Offline
2 posts
since Oct 2006
Oct 26th, 2006
0

Re: Help Java novice

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.
Reputation Points: 22
Solved Threads: 11
Posting Whiz in Training
DavidRyan is offline Offline
229 posts
since Jul 2006
Oct 29th, 2006
0

Re: Help Java novice

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
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Telnet into Server
Next Thread in Java Forum Timeline: I think Loop problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC