Accessing the computers clock/time. Possible?

Hi everyone,I'm pretty new at Java and I was wondering if there was anyway to access the clock on your computer. Or if there was a class that would set the correct time with time zones. Thanks
[207 byte] By [dopey007a] at [2007-11-27 4:44:17]
# 1
Several classes: Date, Calendar, GregorianCalendar, System.You might want to check them all out to see which fits your needs.
floundera at 2007-7-12 9:56:15 > top of Java-index,Java Essentials,New To Java...
# 2

> Hi everyone,

>

> I'm pretty new at Java and I was wondering if there

> was anyway to access the clock on your computer. Or

> if there was a class that would set the correct time

> with time zones.

There are multiple things about this statement that concern me. Let's start with the bigger one, are you trying to fiddle with the actual hardware or OS clock here?

cotton.ma at 2007-7-12 9:56:15 > top of Java-index,Java Essentials,New To Java...
# 3
Refer to java.hidden.God...and don't tell anyone I told you about this.
ktm5124a at 2007-7-12 9:56:15 > top of Java-index,Java Essentials,New To Java...
# 4

Hiii dude , here is a small program , I think it will help you -->

class TestDate

{

public static void main(String[] args)

{

java.text.SimpleDateFormat simpleFormatter = newjava.text.SimpleDateFormat("dd-MM-yy");

java.util.Date today = new java.util.Date();

String today_date = simpleFormatter.format(today);

System.out.println(today_date);

}

}

For more information check this link-->

http://tns-www.lcs.mit.edu/manuals/java-api-old/java.util.Date.html

thanks,

sb

sb.majumder_07a at 2007-7-12 9:56:15 > top of Java-index,Java Essentials,New To Java...
# 5
I needed one accessing the System time not the date. I wanted to make a method that set one of the clocks to the time on the System.
dopey007a at 2007-7-12 9:56:15 > top of Java-index,Java Essentials,New To Java...
# 6

> I needed one accessing the System time not the date.

> I wanted to make a method that set one of the clocks

> to the time on the System.

Still unclear.

Your computer/OS has an internal clock. Call this the "OS Clock" There is a OS API that can be used to access this.

Your OS probably has a display which displays a time and perhaps a date. This is is not the same as the above. It is an application that is some way uses the above API. If you wish you can refer to this at the "OS Time Display Application"

Often the way OSes work an application ends up with a clock that is initially initialized on start up of the application by the OS Clock above. After that it is independent. You can call this the "Application Clock". Your program (java) has an API to access that value. You could use the API to create your own display. You can call this the "Application Time".

The Java API does NOT allow the following.

- Changes to the Application Clock.

- Changes to the OS Clock

- Reads from the OS Clock

So using the terms above what do you want to do?

jschella at 2007-7-12 9:56:15 > top of Java-index,Java Essentials,New To Java...
# 7
If you want to get the "system time" usenew java.util.Date() (the Date also has the time information)orSystem.currentTimeMillis() (milliseconds from midnight, January 1, 1970 UTC)[]]
S_i_m_ua at 2007-7-12 9:56:15 > top of Java-index,Java Essentials,New To Java...