Displaying the System Time In a Frame.

import javax.swing.*;
public class Window1 {
public static void main(String[] args) {
JFrame win = new JFrame("Window1");
JTextArea Timedata = new JTextArea(10, 30);
win.getContentPane().add(tA);
win.pack();
win.setVisible(true);
tA.setText ("This is an editable text area");
public class TimeData {
private long hours, minutes, seconds;
public TimeData(long millis) {
seconds = (millis/1000)%60;
minutes = (millis/(60*1000))%60;
hours = (millis/(60*60*1000))%24;
public String toTimeString() {
return (String.valueOf(hours) + ":" + String.valueOf(minutes) + ":" + String.valueOf(seconds));
public long getHours() { return hours; }
public long getMinutes() { return minutes; }
public long getSeconds() { return seconds; }
public class SystemTimeTest {
public static void main(String[] args) {
String s1;
TimeData t1;
t1 = new TimeData (System.currentTimeMillis());
s1 = t1.toTimeString();
System.out.println(s1);
// How do you get the system time to display in the frame, using the above classes. unable to find the information through books and online tutorials. Please Help.

In future Swing related questions should be posted into the Swing forum.
I am not sure what tutorials you are using but they can't be very good if you did this. Try this tutorial instead http://java.sun.com/docs/books/tutorial/uiswing/components/index.html
And please post some code that might compile without syntax errors next time.
JTextArea Timedata = new JTextArea(10, 30);
win.getContentPane().add(tA);There is no tA defined anywhere.

Similar Messages

  • Please provide an example of how to display the system time in CNiNumEdit.

    I need to display elapsed time in a numeric edit control. The value must be a double. Using MFC, please show me an example that displays the system time in a CNiNumEdit control.

    The trick is to set the FormatString of the num edit control to a format that displays dates/times and to use the COleDateTime class to handle converting the date/time to a double. COleDateTime encapsulates time stored as a DATE, which is a typedef for double. COleDateTime uses the same conversion factor for date/time as what the num edit expects, and since it supports a conversion operator to a DATE, which is really a double, and the num edit Value property is a double, displaying the current time in a num edit can be as simple as this:
    // Assuming you have a member variable called m_numEdit for a CNiNumEdit
    m_numEdit.FormatString = _T("hh:nn:ss");
    m_numEdit.Value = COleDateTime::GetCurrentTime();
    Hope this helps.
    - Elton

  • How to display the Date Time using the System Time zone

    Friends,
    Can anyone help me with below scenario..
    I have to display Date Time on a jsff page, This value associated to one of Transient View object populated from the database.. Is there any way I can handle on the screen to display the same date /time bassed on the system time zone ?
    I know one way how we can handle it.. while populating to View object we can set the time based on the system time zone.. but it would be easy and simple if there is any approach I can use on UI layer itself..
    thanks

    I don't understand why this display doesn't pay attention to the date/time format settings that are set in the language and text prefs.
    Those settings are used for date OR time, and provide for different displays depending on the space available. The menu bar does not have a fixed space available, and wants both date and time.
    In Leopard, it used the medium time format. To get the date and time, you could modify that format to include the date, but that could cause problems with software that happened to use the medium time format and expectede just the time. Also, you might want to change the medium time format without changing the menu bar display. For these reasons, Snow Leopard's menu bar clock uses its own formatting for data and time display.

  • How can I display the elapsed time of the course using Advanced Actions in Captivate?

    I have a Captivate course which is approximately 35 minutes in length. On each slide I would like to display to the user, the current elapsed time.
    EXAMPLE:
    25/35 minutes complete
    The 35 would remain static, so I have been working with the elapsed time system variable in CP: elapsed:$$cpInfoElapsedTimeMS$$
    I can't seem to get the variable to properly display the elapsed time in minutes, rather than miliseconds. Attached is a screen shot of my advanced action.
    Can anyone provide guidence regarding how I should structure this differntly?

    I talked about that Timer widget in that blog post and pointed to another one:
    http://blog.lilybiri.com/timer-widget-to-stress-your-learners
    If you are on CP7, you'll have this widget also as an interaction, which means it is compatible with HTML5 output. Amd there is also an hourglass interaction, with similar functionality but... did not blog about that one
    PS: Check Gallery\Widgets to find all widgets. Default path is set to Interactions

  • How to display the current time in a UIX page

    Hi All,
    another UIX question....
    A requirement of a customer is to display to current data and time in every page.
    It should be done in a <header>. So i'm writing a new (template based) renderer for that element. How can i display the current time and date on it?
    Thanks in advance for any help...
    Regards,
    Robert Willems

    Hi Robert -
    When you say you are writing a template-based Renderer, do you mean that you are creating a custom look and feel and replacing the header Renderer? If so, I'd recommend instead simply creating your own template (not template-based Renderer), and reference your template directly from your uiXML pages where you want to insert the timestamp.
    You'll probably want to write a method data provider which calls System.currentTime(), convert the result to a date, and then use Java's date formatting capabilities (see java.text.format.DateFormat) to produce a user presentable String that you can return from your data provider.
    For more info (and samples) on templates and data binding, see the "Templates and Data Binding" section of the "Includes and Templating in ADF UIX" help topic:
    http://tinyurl.com/5b7bf
    Andy

  • How we can display the running time as an output by writting abap report?

    hi to all,
         my name ahmed iam just abap fresher.i know java/j2ee very well.
    i want to display the runing time as an output of abap report.Is it possible if possible how.

    Hi,
    system field  SY-UZEIT
    WRITE : SY-UZEIT.
    Regards,
    V.Balaji
    Reward if Usefull...

  • Accuracy of checking the system time -- how many ms?

    I'm creating a program for a university lab which will display a number of reading and comprehension tests to middleschoolers.
    For most of the tests, I need a fairly accurate measure of reaction times, preferably within about 1-5 milliseconds.
    In my program, I
    1) Display a stimulus
    2) Get the start time, using System.currentTimeMillis();
    3) Wait for the user to press a button
    4) Get end time, using System.currentTimeMillis();
    I will be displaying these in public schools, which may be using Win XP, 2000, 95, or Mac OS X.
    1) How accurate can I expect the System.currentTimeMillis(); to be? Is there any delay between the user hitting a button and formKeyPressed(KeyEvent evt) being called?
    2) Is there any way to test the accuracy of a computer from within the program? Is it possible that a seven-year-old computer would introduce inaccuracies of over, say, 5 ms?
    Thanks for any help regarding these questions.

    I'm creating a program for a university lab which
    will display a number of reading and comprehension
    tests to middleschoolers.
    For most of the tests, I need a fairly accurate
    measure of reaction times, preferably within about
    1-5 milliseconds.
    Uh-oh.
    In my program, I
    1) Display a stimulus
    2) Get the start time, using
    System.currentTimeMillis();
    3) Wait for the user to press a button
    4) Get end time, using System.currentTimeMillis();
    I will be displaying these in public schools, which
    may be using Win XP, 2000, 95, or Mac OS X.
    1) How accurate can I expect the
    System.currentTimeMillis(); to be? For Windows at least 10 ms. Maybe more or less depending on mileage.
    Is there any delay
    between the user hitting a button and
    formKeyPressed(KeyEvent evt) being called?
    There are some Windows related bugs in getting the system time that can throw the whole thing into some chaos as well.
    2) Is there any way to test the accuracy of a
    computer from within the program? Sorry what? Anyway like I said repeated system time calls on Windows will do funny things to the clock (like accelerate it). This is a Windows bug on some versions (if not all) of what you mentioned.

  • How to View Outlook Messages in Timezone different from the Systems Time.

    Hi Team,
    My Name is Abhishek. I am from India.
    I just want to know one thing related to MS Outlook 2007 Version.
    To deal with Hongkong customers and to work in database we have kept the systems time as HongKong Time (GMT + 07: 30) in my official Laptop.
    So. when I receive any email in the Inbox it shows the message received time in Hong Kong Time which is the systems Time right now.
    But As I stay in India, I just want to see my all Outllook received Messages in Indian Time (GMT + 05: 30), without disturbing the systems time.  I just get confused when I receive any email and it shows in systems Hong Kong Time.
    Is it possible to change my outlook message receiving display time to Indian time without disturbing my systems time...If so, pls help me by telling the procedure how to do it...
    Thanking You
    Abhishek

    Hi Abhishek:
    There are no
    Daylight saving time for  HongKong Time Zone and also for the Indian Time, so the checkbox will be greyed out.
    As
    Nezer mentioned above: “Adjusting the time zone in outlook also alters the system time, I think outlook is design to always mirror the time zone of you system clock.” We couldn’t change
    this within Outlook.
    Thanks for your understanding.

  • How can i get the System Time from the other host

    I want to get the System Time from the other host in the LAN,How can I get the Time using Java.
    Such as I am in WIN 2000 and I have a Unix host in LAN, I want to get unix host System time, How can I do it.

    Open a socket to port 13 and read a string with the time.
    -or-
    Open a socket to port 27 and read 4 bytes that are a network order timestamp
    Assuming that your UNIX machine has those services running, most do

  • How to get the system time in a Swing application ?

    I know how to do it in JavaScript, but not java. Please help me, and also how to get the system time in an Applet. Thanks !!!

    Check this link, I hope it helps
    http://202.71.136.142:8080/globalleafs/Swing/View.jsp?slno=22&tbl=0

  • Function Module for getting the System time.

    Hello All,
    Which is the Function Module used in APO to get the system time?
    Thanks for your response in advance.
    Regards, Chirag

    Hi Chirag,
    Please try the following function modules
    1) /SAPAPO/CRES_GET_TIMESTREAM_BT
    2) /SAPAPO/OM_TIME_GET
    The field name for system time is UZEIT under
    structure SYST
    Also try
    3) CALENDAR_GET_TIMESTAMP
    4) SAL_CSM_RECEIVER
    I guess the third one will have your required data
    Regards
    R. Senthil Mareeswaran.

  • Is it possible to stop the system time outs on my imac ,i have tried 5 times in the last 24 hrs.each time it will go for maybe 3hrs and then times out.each time i have to start the download all over again,thanks,

    is it possible to stop the system time out on my imac? i have tried 5 times in the last 24 hrs.it will run for approx.3hrs,and then times out and i have to start
    from the beggining again

    What is the url of the file your are downloading?
    What web browser are you using?
    What type of connection do you have to your isp?  phone line, dsl, cable, fios...
    Try iCab.  It lets you restart a download.
    icab.de
    Robert

  • How to set the system time in the program

    Hi All,
    How do we update the system time inside java programme.

    AFAIK there is no easy (pure java) way: either you exec something (depending on your paltform) or use native code. Appropriate privileges will be necessary.

  • I need to get the system time in Micro second

    Hi,
    In the java API there is a static method �curentTimeMillis�, but I need
    to get the system time in Micro second there is a equivalent method? Or
    there exists any suggested solution?
    Thanks
    Dany

    Why do you need such accurate timing ?
    I'd be suprised if anyone seriously relies on millisecond timing in
    Java, never mind calling through to JNI to get microsecond timing.
    If that's even possible in native code.
    The garbage collector can cause delays/pauses in a java program and
    throw timings off by at least 500 milliseconds, probably more under big loads.
    If you just want a more accuruate way to reset a random seed, there's probably other ways...
    regards,
    Owen

  • To get the system time in milliseconds

    i want to get the system time in milliseconds
    eventhough the MLS(milliseconds) is given in the select statement as follows,
    sql>select to_char(sysdate,'MON:DD:YYYY.HH:HH:MI:SS:MLS') "NOW" from dual;
    does not seem to work.
    it throws the error that
    ORA-01821: date format not recognized
    please give a solution
    thanks in advance
    null

    Hi,
    Yes, any of Oracle tools could not provide the milliseconds.
    Then why cant not use external procedures (RPC) and get a time string from OS.
    These are steps:
    1. Create a C shared library.
    (Some times U have to go for OCI programs.)
    Milliseconds provision is there in C. ( use tm struct). Make a string as ur format by using any string functions in C or sprintf(). By using return, return this string.
    Here error may come, if u are using pure C. Better to go for OCI call back methods.
    2. Create oracle library and attach this shared libary with it.
    3. Create external procedure/function and connect this.
    If u want code, I can post it here.
    with regards,
    Boby Jose Thekkanth,
    Dharma Computers(P) Ltd.
    Bangalore-India.
    www.dharma.com.
    null

Maybe you are looking for

  • CIF issue u201CNo data in table TRFCQDATA selected (internal )u201D

    Hi SAP Gurus, I am facing CIF issue in R/3 quality system after this system has been refreshed with production. When i try to activate the integration model for any data, the inbound queues are failing with status "u201CNo data in table TRFCQDATA sel

  • Service account for Windows Update sync

    Hi all, I would like to know if it's possible to change service account used by WSUS 2008R2 SP1 to sync with Windows Update servers, and if so how. Thanks. Have a good day. FXE

  • Change image tool name box

    Hello, I'm working with labview development vision 2011. I'm creating a software with image tools and i need that the name of a indicator changes when i click in a specific tool. Example - When I click in the Point tool, the name of the indicatior ne

  • Assigning receiving plant for customer !

    I want to maintain the plant for a customer 51(in sales order).this plant is the receiving plant for deliveries (& different frm the plant in sales order ,though values may b same) and can be maintained for tht particular customer. In LIKP table, Wer

  • Problem fetching File Path

    Hi I kept my file in D:\test\com\Login.class and specified the classpath as D:\test I am trying to run the above program from C:\ using the following command C:\>java com.Login Prgram executing perfectly. My problem is, i want to fetch the path for t