Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2011
    Posts
    93
    Rep Power
    0

    Default Compiler chokes on Date object

    Hello. I'm trying to write a program using a Date object representing the current moment. It doesn't matter whether the date is in year/month/day/millisecond format or just the number of milliseconds since Jan. 1, 1970 (tho I prefer the later).

    Yet my compiler tells me "error: cannot find symbol", referencing the line creating the date object. So I'm thinking I am using the Date constuctor wrong. Can anyone show me the correct way to do this?

    Here is the code:
    Java Code:
    public class Watch {
    	public static void main(String[] args) {
    		int sw = Integer.parseInt(args[0]);
    		int d;
    		Date today = new Date();
    		d = getTime(today);
    		System.out.print(d);
    	
    	}
    }
    The error message from the compiler:
    Watch.java:7: error: cannot find symbol
    Date today = new Date();

    Thank you.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Compiler chokes on Date object

    You will have to import the Date class in oder to use it. Check the API docs to find the package it's in. The one you want is *not* the database (JDBC) Date.

Similar Threads

  1. How to use java Date object??
    By bczm8703 in forum NetBeans
    Replies: 1
    Last Post: 03-25-2011, 02:26 PM
  2. Clear the Date object for cron
    By soichi in forum New To Java
    Replies: 3
    Last Post: 01-24-2011, 12:21 PM
  3. Calendar object? - Getting date from user
    By hiei_yasha in forum New To Java
    Replies: 9
    Last Post: 01-23-2011, 03:58 AM
  4. Problem with Date Object
    By R O C K Y in forum Advanced Java
    Replies: 4
    Last Post: 02-15-2009, 04:37 PM
  5. Creating a Gregorian Calendar using a Date object gives date - 1
    By prachi_goliwadekar in forum New To Java
    Replies: 1
    Last Post: 05-08-2008, 08:32 PM

Posting Permissions

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