File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
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: 60737
    
  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
 
jQuery in Action, 2nd edition
 
subject: How to get System Date and time
 
Similar Threads
how to get system date and format it
<bean:write/> of struts1
how to get system date and format it
How to get System Date and time
compare two dates thru Calendar