aspose file tools*
The moose likes Beginning Java and the fly likes How to get System Date and time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to get System Date and time" Watch "How to get System Date and time" New topic
Author

How to get System Date and time

Bhasker Reddy
Ranch Hand

Joined: Jun 13, 2000
Posts: 176
I am trying to save a xml file. I want to retrieve
the system date and name the file as systemdate
stamp like mmddyyhrminutes(in this format).
Do you know how to retrieve system date and
format it in that way


Bhasker Reddy
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

You can get the current date/time by simply creating a java.util.Date instance with the default constructor. If you need to use a java.sql.Date for whatever reason, you need to initialize it as new java.sql.Date( System.currentTimeMillis() ).
You can format the date as you like using a java.text.DateFormat instance.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Moving this from Servlets -> Java In General - Beginner
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get System Date and time
 
Similar Threads
how to get system date and format it
How to get System Date and time
compare two dates thru Calendar
<bean:write/> of struts1
how to get system date and format it