Results 1 to 5 of 5
  1. #1
    juan4412 is offline Member
    Join Date
    Jun 2013
    Posts
    6
    Rep Power
    0

    Default Date Compile Errors

    I use code this
    Java Code:
    Scanner input = new Scanner(System.in);
    Date d;
    System.out.println("");
    int month = input.nextInt();
    int day = input.nextInt();
    int year = input.nextInt();
    d = new Date(month, day, year);
    System.out.println("Output ' + d.nextDay());
    }
    //This is what causes
    //my debug problem
    return new Date(month, day, year);
    Compiler tells me that day cannot be resolved to a variable, month..., year.... same error on all 3 variables in my return statement?

  2. #2
    jbarke12's Avatar
    jbarke12 is offline Member
    Join Date
    May 2013
    Location
    Charleston, South Carolina USA
    Posts
    88
    Rep Power
    0

    Default Re: Date Compile Errors

    Date is depreciated as of JDK 1.1 try using Calendar or Gregorian Calendar and it should work.

  3. #3
    juan4412 is offline Member
    Join Date
    Jun 2013
    Posts
    6
    Rep Power
    0

    Default Re: Date Compile Errors

    Can you provide an example that fits my scenario above? I attempted to use
    Java Code:
     Date d;
    d = new GregorianCalendar(month, day, year);
    but that tells me that cannot convert from GregorianCalendar to date

  4. #4
    juan4412 is offline Member
    Join Date
    Jun 2013
    Posts
    6
    Rep Power
    0

    Default Re: Date Compile Errors

    I modified my code just a little and have removed the error above, but am on to another. This is how I modified
    Java Code:
    int month = 0;
    int day = 0;
    int year = 0;
    for(int I = 1;i <= 365; i++)
    {
    Scanner input = new Scanner(System.in);
    
    //and more code below
    The new compile error I am receiving is that
    Resource Leak: 'Input' is never closed

    What would correct that?
    Last edited by juan4412; 06-04-2013 at 12:02 AM.

  5. #5
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Location
    Sweden
    Posts
    268
    Rep Power
    2

    Default Re: Date Compile Errors

    after you do whatever you do, type
    Java Code:
    input.close();

Similar Threads

  1. SetterGetter won't compile without errors?
    By doreilly15 in forum New To Java
    Replies: 4
    Last Post: 02-08-2012, 07:51 AM
  2. help with compile errors
    By bzupnick in forum New To Java
    Replies: 1
    Last Post: 02-15-2011, 09:14 PM
  3. Replies: 4
    Last Post: 01-04-2011, 01:36 AM
  4. compile errors (how do I fix)
    By rhythmiccycle in forum New To Java
    Replies: 4
    Last Post: 01-03-2011, 11:33 PM
  5. Compile Errors and need to add a second static
    By lk1001 in forum New To Java
    Replies: 5
    Last Post: 03-05-2010, 12:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •