ok, yes this is a homework help question, and no i don't want just the answer. i actually really want to learn this.

Ok, so I have to the simple date format that displays today's date in "week day month day, year)

so here is what i got:

import java.text.*; //for SimpleDateFormat
import java.util.*; // for Date
public class date {
    public static void main(String[] args) {
        date today;
        today= new date();
        [COLOR="Red"]sdf[/COLOR] = new SimpleDateFormat ("EEEE MMMM DD, YYYY");
        System.out.println("Today is" + sdf.format(today));
        /**
         * @param args
         */ 
            // TODO Auto-generated method stub
        }
    }

ok, so it looks pretty good, excpet that stinkin java won't read the "sdf". So i don't know what i am doing wrong with it. Any help or tips would be greatly appriciated.
Remember, i am not looking just for the answer, i really do want to learn this stuff.

Re: simple date format 80 80

...ugh...

ok, so then i got the sdf to work, and then it gave me a warning that the java.util, was never used...so then i fixed that (not really sure how, but the warning went away) and not it won't read the sdf again.

so here is what my code looks like now:

import java.text.*; //for SimpleDateFormat
import java.util.*; // for Date
public class date {
	public static void main(String[] args) {
		date today;
		today= new date();
		today.toString();
		sdf1.format(today);
		sdf1 = new SimpleDateFormat ("EEEE MMMM DD, YYYY");
		System.out.println("Today is" + sdf1.format(today));
		/**
		 * @param args
		 */	
			// TODO Auto-generated method stub
		}
	}

AAHHH, i am about to throw java out the window!!!!! Please help!

Re: simple date format 80 80

SimpleDateFormats will only format Date objects (or classes that extend Date). They won't work on your date class.

Re: simple date format 80 80

ok, so then what do i need to do to fix it? Sorry, I am very new to this, i don't know what i am doing.

Re: simple date format 80 80

"stinkin java won't read the "sdf"" because you haven't "stinkin" declared it properly in any of the code you posted. You would need to do this:

SimpleDateFormat  sdf = new SimpleDateFormat ("EEEE MMMM DD, YYYY");

and even then, masijade's right - it isn't going to work your class just because you called it "date".

Re: simple date format 80 80

thanks for ya'lls help. I figured out what ya'll were saying and I got it to work! yay me!

Re: simple date format 80 80

Try putting SimpleDateFormat infornt of sdf

SimpleDateFormat sdf = new SimpleDateFormat ("EEEE MMMM DD, YYYY");

Re: simple date format 80 80

Try putting SimpleDateFormat infornt of sdf

SimpleDateFormat sdf = new SimpleDateFormat ("EEEE MMMM DD, YYYY");

Well,

1. That's already been said.
2. The OP has declared the problem solved.
3. You didn't notice that today was declared today=new date() rather than today=new Date() .

Re: simple date format 80 80

Well,

1. That's already been said.
2. The OP has declared the problem solved.
3. You didn't notice that today was declared today=new date() rather than today=new Date() .

And

4. This thread is 15 days old. Try to solve more current threads

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.