Simple Date/Time Question

ok so I can print out the date and time when i run the program.
How would I write a method that updated the clock every second, kinda like a digital watch. would I just use a while loop? or does java have an actual running clock?
Here is the code I have so far:
import java.util.Date;
public class DateTime
     Date now = new Date();
     public DateTime()
          System.out.println(now);
      public static void main(String[] args)
           DateTime run = new DateTime();
}

import java.util.Date;
public class DateTime
     Date now = new Date();
     public DateTime()
     {while(true){
          System.out.println(now);now = new Date();
Thread.sleep(1000);
     public static void main(String[] args)
          DateTime run = new DateTime();
I modified your code a bit better do this in a different thread though if you plan to use a GUI

Similar Messages

  • Insert Date & Time question

    Does anyone know if there is a way to DESELECT the "Automatically update the date and time when the document is opened" dialog?
    Thanks.
    Paul

    The only way I can see is to create your own template with this unchecked. Then, when you open this template, auto date & time should be unchecked.
    It would be nice if this were a global preference. I suggest you leave feedback for the Pages team.

  • Date/Time Questions

    Hi, I'm a new Java programmer.
    I need to format a date/time variable from sql server into two string objects. One string object storing the date and the other storing the time.
    I've tried using the Date class and DateFormat class, but I haven't found a way yet.
    Can anyone help me?
    Thanks a lot,
    louis

    You could try something like this:
    Date dateAndTime = /* read date from sql server */;
    DateFormat dateOnly = new SimpleDateFormat("yyyy-MM-dd");
    DateFormat timeOnly = new SimpleDateFormat("HH:mm:ss");
    String dateString = dateOnly.format(dateAndTime);
    String timeString = timeOnly.format(dateAndTime);

  • Date + Time question updating to a DATE field..

    Hi,
    I'm going crazy...
    MEETING_DATE is a DATE column in the DB
    :P40_MEETING_DATE is a TEXT FIELD with source MEETING_DATE
    :P40_MEETING_DATE:=to_char(to_date('02-OCT-2006 09:14:45 PM','DD-MON-YYYY HH:MI:SS PM'),'DD-MON-YYYY HH24:MI:SS');
    Ultimately I need to have :P40_MEETING_DATE a date picker and then
    add a character string of a time to it.
    :P40_MEETING_DATE:=to_date(to_char(:P40_MEETING_DATE,'date picker format?')||' '||:P40_START_TIME,'date picker format?');
    I get all kinds of errors ORA-01858 errors.. non- numeric errors.. invalid month errors..
    Bill

    You are right, sorry about that.
    I thought about sneaking a On Submit - After Computations and Validations process in there before the Process Row process like this:
    :P216_X := TO_DATE( TRUNC( TO_DATE( :P216_X, 'DD-MON-YY HH24:MI' ) ) || ' ' || :P216_TIME, 'DD-MON-YY HH24:MI' );but that's probably the same thing you tried before.
    I would just turn it into a procedure and pass the parameters...;)
    I hope someone can get your going in the right direction.
    chet

  • Another DATE/TIME question

    HI all
    I am trying to INSERT INTO TABLE a date and time into one line..
    excerpt looks like
    CREATE TABLE Test
    (Submit DATE );
    INSERT INTO Test
    VALUES(to_date('2001-01-02 22:23:00','yyyy-mm-ss hh24:mi:ss'));
    I get an error message that says it's missing a comma (and I can't figure out WHERE). I have tried quotes in different places etc...Is it not possible to put a date and a time in the same slot?
    Thanks in advance

    Try this...
    SQL> create table mytest (submitted date);
    Table created.
    SQL> desc mytest
    Name Null? Type
    SUBMITTED DATE
    SQL> insert into mytest
    2 (SUBMITTED)
    3 values
    4 (to_date('2001-01-02 22:23:00','yyyy-mm-dd hh24:mi:ss'));
    1 row created.
    SQL> select * from mytest;
    SUBMITTED
    02-JAN-01
    HI all
    I am trying to INSERT INTO TABLE a date and time into one line..
    excerpt looks like
    CREATE TABLE Test
    (Submit DATE );
    INSERT INTO Test
    VALUES(to_date('2001-01-02 22:23:00','yyyy-mm-ss hh24:mi:ss'));
    I get an error message that says it's missing a comma (and I can't figure out WHERE). I have tried quotes in different places etc...Is it not possible to put a date and a time in the same slot?
    Thanks in advance

  • Newbie: Date time question

    I want to store a date and time into the same column. But I do not know the syntax to do it and to select it.
    Can anyone help me?

    Oracle should store this anyway - all you need to do to see this is to set the nls_date_format for the session you are using to 'DD-MON-YYYY HH24:MI:SS'
    GR

  • Simple Data Export Question

    Hello,
    I am testing the process-feature of the Livecycle WorkBench.
    However, I am facing some difficulties...
    As a matter of test, I wanted to create a simple process which would:
    Fetch an email attachement, an interactive PDF form
    Export the XML data from the form
    send the XML data by email
    I manage to do step 1, but as soon as I get to step 2, I have the following problem:
    I have the PDF form stored in a variable, of type document, by I cannot use this variable to assign in as input to the "export data" component...
    The export data component seems to expect an asset...
    If I run my process, with the process as input (in the URI format), I get an input exception saying that my PDF is not in a correct format...
    I thought that this test-process would be a simple one
    Could someone show me how to achieve this in a process? Thanks a lot!

    Please seek help from various services samples available here : http://help.adobe.com/en_US/livecycle/9.0/samples/lc_sample_service.html
    Here is the link to all the samples : http://www.adobe.com/devnet/livecycle/samples.html
    Hope this helps.
    Thanks,
    Wasil

  • Date/Time Question - Milliseconds

    How can I get the number of milliseconds after the 1970... from a date?
    Is there such a method in the API? I looked at the DateFormat and NumberFormat classes but I didn't find it... Is there a way a to do this?
    I want to be able to give a date and get back the number of milliseconds past the 1970 thing...
    Thanx

    DrClap has a good solution. Here is another twist:
    // Do this
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    Date start = formatter.parse("01/01/1970");
    // Or do this
    Calendar calendar = Calendar.getInstance();
    Calendar.set(1970, Calendar.JANUARY, 1);
    Date start = calendar.getTime();
    return (new Date().getTime() - start.getTime());- Saish

  • Adding Date/Time Field + X Number of Days - Basic Calculation Question

    I am assuming this is a basic calculation question. New to Adobe LiveCycle Forms.
    I have a simple form containing a table. The table appears as such:
    Text
    Formatted as Date/Time Fields
    Header 3
    Monday
    user wil choose the beginning date (Date/Time) this is DateTimeField1
    Tuesday
    this should calculate DateTimeField1 + 1
    Wednesday
    this should calculate DateTimeField1 + 2
    Thursday
    this should calculate DateTimeField1 + 3
    Friday
    this should calculate DateTimeField1 + 4
    Saturday
    this should calculate DateTimeField1 + 5
    Sunday
    this should calculate DateTimeField1 + 6
    Calculations are performed after the date is chosen for Monday. My mind tells me the simple calculation of DateTimeField1 + 1 is not going to work (and in fact doesn't!) as it needs to change Monday to a number first. I saw on another thread the following:
    Num2Date(Date2Num(Date(DateTimeField1), "DD.MM.YYYY")+7, "DD.MM.YYYY")
    Thought this was going to get me close. No cigars though!
    Any quick help is greatly appreciated. And since I am new to this, details about what needs to be changed would be great too!
    Thanks

    Here an addition for you date field.
    This FormCalc script in the exit:Event will check it the selected date is on a monday.
    If not it will go the days back until the last monday.
    var Selection = Date2Num($.formattedValue, DateFmt(2))
    var WeekDay = Num2Date(Selection, "E")
    var NewDate
    if (WeekDay eq 1) then
              NewDate = Selection - 6
    elseif (WeekDay eq 3) then
              NewDate = Selection - 1
    elseif (WeekDay eq 4) then
              NewDate = Selection - 2
    elseif (WeekDay eq 5) then
              NewDate = Selection - 3
    elseif (WeekDay eq 6) then
              NewDate = Selection - 4
    elseif (WeekDay eq 7) then
              NewDate = Selection - 5
    else
              NewDate = Selection
    endif
    $ = Num2Date(NewDate, "EEE DD.MM.YYYY")
    Hope this helps, too.

  • Question on date, time and time stamp related - high priority

    Hi friends,
         My requirement is to find the processing time (time taken) of a task done by an agent in wf. For that I use Start Date, Start Time, End Date and End Time ( from struc SWP_LOGTAB ). I have to display the time taken by an agent in the form WWd XXh YYm (or WWd XXh YYm ZZs) ex: 2d 10h 40m 20s.
    Can any one suggest me the right FMs which take start and end date/time and give me the above format result?
    This can be achieved manually with unnecessary Ifs and CASEs but its gonna be a performance issue. Please suggest me something SAP standard.
    Thanks in advace for your help
    Reddy

    Hi,
    I don't find any function module, but it does'nt really hard to code this using DIV and MOD instructions :
    If you've got your time in seconds :
    w_day = w_time DIV 86400.
    w_mod = w_time MOD 86400.
    w_hour = w_mod DIV 3600.
    w_mod = w_mod MOD 3600.
    It doesn't seem too bad in term of performance....
    Mathieu

  • Adobe LiveCycle Date/Time Field Scripting Question

    I have a date/time field in Livecycle which the end user chooses a random date from.  I need to populate a date 180 days from this date for an eligible to date/time field.  I have tried various javascript and formcalc options with no success.

    Try this site here for a reference: http://eslifeline.wordpress.com/2008/09/26/date-manipulation/
    The following was the use case. A form has 2 TextFields Start_Date and End_date
    User enters a certain date in the Start_Date text field for example 09/24/08 (MM/DD/YY)
    The End_Date should add 90 days to the Start_date and populate the End_Date
    The following script would do that
    var current = Date2Num(Start_Date.rawValue, “MM/DD/YY”)
    var future = current+90
    var newDate = Num2Date(future,”MM/DD/YY”)
    form1.#subform[0].End_Date.rawValue = newDate 
    Validating End Date is later than Start Date
    var diff = Date2Num(EndingDate.rawValue, “YYYY-MM-DD”) – Date2Num(StartingDate.rawValue, “YYYY-MM-DD”)
    if (diff > 0) then
    xfa.host.messageBox(“The End date is later than start date”)
    else
    xfa.host.messageBox(“PLEASE CHECK….The End date is before the start date”)
    endif

  • Time Zone Offset - Date Format question

    I'm wondering if any one knows how to display the time zone offset of a date in the following format "[+-]HH:mm." More so... I need the date/time in the ISO 8601 format "yyyy-MM-dd'T'HH:mm:ss[+-]HH:mm", where the last [+-]HH:mm is the hour representation of the offset. Here's some sample code...
    SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    Calendar rightnow= Calendar.getInstance();
    // So if system date/time is February 14, 2002 at 1:15:00 PM EST, this would produce "2002-02-14T13:15:00"
    System.out.println("Current Datetime" + sdf1.format rightnow.getTime());
    How can I get the timezone offset appended to my output in a [+-]HH:mm format. So, the above date needs to look like "2002-02-14T13:15:00-05:00". I can get the offset in milliseconds by doing the following:
    int offset1 = rightnow.get(rightnow.ZONE_OFFSET) + rightnow.get(rightnow.DST_OFFSET);
    But how can you get this representation into the [+-]HH:mm format?
    thanks in advance,
    stophman

    Try something like this:import java.text.* ;
    import java.util.* ;
    static public String formatISO8601(Calendar cal) {
         * create ISO 8601 formatter for Calendar objects
        MessageFormat iso8601 = new MessageFormat("{0,time}{1,number,+00;-00}:{2,number,00}") ;
        // need to shove a date formatter that is cognizant of the
        // calendar's time zone into the message formatter
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss") ;
        df.setTimeZone(cal.getTimeZone()) ;
        iso8601.setFormat(0, df) ;
         * calculate the time zone offset from UTC in hours and minutes at the current time
        long zoneOff = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET) ;
        zoneOff /= 60000L ;  // in minutes
        int zoneHrs = (int) (zoneOff / 60L) ;
        int zoneMins = (int) (zoneOff % 60L) ;
        if (zoneMins < 0) zoneMins = -zoneMins ;
        return (iso8601.format(new Object[] {
                                    cal.getTime(),
                                    new Integer(zoneHrs),
                                    new Integer(zoneMins)
    }

  • Question on date, time and time stamp related

    Hi friends,
         My requirement is to find the processing time (time taken) of a task done by an agent in wf. For that I use Start Date, Start Time, End Date and End Time ( from struc SWP_LOGTAB ). I have to display the time taken by an agent in the form WWd XXh YYm (or WWd XXh YYm ZZs) ex: 2d 10h 40m 20s.
    Can any one suggest me the right FMs which take start and end date/time and give me the above format result?
    This can be achieved manually with unnecessary Ifs and CASEs but its gonna be a performance issue. Please suggest me something SAP standard.
    Thankful for your help
    Reddy

    Hi
    I will refer you to use SWWIHEAD table to retrieve start date and End Date of a Task. You have to write aprogram for this. You can find out the task from the field TS94000083 from WI_RH_TASK.
    <b>Please provide points if useful</b>
    Thanks
    Arghadip

  • Date/time theme, and audio question

    I have a video about 45 min long. I have dragged the date/time theme to each thumbnail section, but sometimes it won't allow me to drop it into the whole thumbnail, only a part of it. Is there a fix?
    Also, can you drop the date/time theme into the whole video, without having to do each thumbnail?
    How do I transfer my video to a dvd without sound?
    Thanks!

    I have dragged the date/time theme to each thumbnail section, but sometimes it won't allow me to > drop it into the whole thumbnail, only a part of it. Is there a fix?
    Have you tried dragging the left handle (and dragging to the left) or the right handle) and (dragging to the right) to lengthen the Title?
    You must do titles one at a time.
    How do I transfer my video to a dvd without sound?
    You can set the volume for a clip by clicking on the inspector icon for the clip (looks like a little gear inside the clip). Select Audio Adjustments. And move the volume slider to zero.
    If you want to do this for all clips, select the clip you just adjusted and click, EDIT/COPY.
    Now click EDIT/SELECT ALL.
    Finally click EDIT/PASTE ADJUSTMENTS/AUDIO.

  • Date / Time stored as Number(22,0) question

    I've been working with a database (i'm not the author) who's date/time stamp is stored as a number(22,0) within the database.
    I need pull out the date and convert. It appears to be an 18 character number. Is there a method, stored procedures, function, etc. that will conver this to a date that I'm overlooking?
    Example:
    129744082444876330
    thanks,
    Bob

    rconnellii wrote:
    I've been working with a database (i'm not the author) who's date/time stamp is stored as a number(22,0) within the database.
    I need pull out the date and convert. It appears to be an 18 character number. Is there a method, stored procedures, function, etc. that will conver this to a date that I'm overlooking? Sounds like Unix time. Easily handled using a (deterministic) user defined PL/SQL function, or native SQL (if performance is of concern).

Maybe you are looking for