This week's book giveaway is in the Python forum.
We're giving away four copies of Hello World and have Warren & Carter Sande on-line!
See this thread for details.
Win a copy of Hello World this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Date class

 
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.
 
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.
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!