File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Date class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date class" Watch "Date class" New topic

Date class

Sean Ayles

Joined: Mar 13, 2002
Posts: 2
I'm new to Java and trying to format dates both current date and dates since jan 1 1970. I have looked at the api documentation and it isn't very clear how I use the Date class.
I'm trying to get seconds, minutes, days, etc since jan 1, 1970. And I also need to get the current date in the format mm/dd/yyyy-hh:mm:ss.
Any help would be appreciated, thanks.
By the way I am able to use
System.out.println("date: " + new Date());
//Sun Mar 17 19:47:20 PST 2002
but I get an error when I try and store this into a variable of type String.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

That's a gold-mine question in this forum.

Use the search function (it's in between the Post New Topic and Post Reply buttons) and search for "SimpleDateFormat"
Sean Ayles

Joined: Mar 13, 2002
Posts: 2
Great thanks.
I agree. Here's the link:
subject: Date class
It's not a secret anymore!