• 0

[Java] Date()?


Question

http://www-csfy.cs.ualberta.ca/~c114/F04/j.../util/Date.html I was given this link by a prof and i am wondering how i can use this date thing to print out the date in a format such as this one: Tue Sept 21 15:32:07 MDT 1999

I am new to java so please try and make the explanation easy to understand

PS: This is for a homework assignment so don't flame me, just asking for help is all

Thanks

-Asmo

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

so this means that i must use the calendar class and not the date class, this is what i though however i beleive my school is using an older version of JDK(1.0) so i think i may still have to use this Date() which would explain why i can't get it to work on my home system cause i am using the newest version of JDK hehe

Link to comment
Share on other sites

  • 0

Newer JDKs are backward compatible with older JDKs so the fact that you are using a newer JDK is NOT the cause of your problem. Most of the methods on the Date class have been deprecated which does not prevent you from using the class... the deprecation is simply a warning that there are other, usually newer options available and that, if possible, you should use those instead.

If you are supposed to use the Date class then you can simply instantiate a new instance of Date and use the "getX()" methods for Date, Minutes, Hours, etc. If you are not required to use the Date class, then use the equivalent methods on Calendar. Note that you can't instantiate the Calendar class directly; you must call the static "getInstance()" method:

Calendar cal = Calendar.getInstance();

The easiest way to do what you want to do, though, is to use the DateFormat class...

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.