• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date class

 
Sean Ayles
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic