wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes getting System time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getting System time" Watch "getting System time" New topic
Author

getting System time

kavya krushi
Ranch Hand

Joined: Oct 25, 2000
Posts: 48

Hi all,
Is there any way to get the systems time through a java program ?
I tried using the getProperties option but it just gives informations related to Zone ... I need to get the Systems time during which a program of mine is running ...
thanks
kavya
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi Kayva,
You can get the current system time using <code>java.util.Date();</code>
Hope that helps.
------------------
Jane Griscti
Sun Certified Java 2 Programmer
"When ideas fail, words come in very handy" -- Goethe


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
I think it's best to use System class for this and get the time from the System. Using System.currentTimeMillis()


Val SCJP <BR>going for SCJD
kavya krushi
Ranch Hand

Joined: Oct 25, 2000
Posts: 48

Jane , val
Thanks alot for your responces ... I'd already tried both of these options ... I need to get the timing info in the actual format ( not just milliseconds) ... I tried the toString method but it does not seem to work ... is there any particular method
which prints the time/date in the actual format ???
thanks
kavya
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
Use SimpleDateFormat class to format the date to look how you like.
Art Metzer
Ranch Hand

Joined: Oct 31, 2000
Posts: 241
Hi, Kavya. Here's some code to help you out:

See also this Sun link for more about customizing date and time formats using java.text.SimpleDateFormat.
Hope this helps,
Art
kavya krushi
Ranch Hand

Joined: Oct 25, 2000
Posts: 48

Thanks Art...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting System time
 
Similar Threads
Yet to get the Much Awaited Email, However Score Report in PearsonVue says Pass.
help
What happens when the client doesn't know what they want?
getFiles from Unix System
Alternatives to Jess?