Results 1 to 4 of 4

Thread: date functions

  1. #1

    Thread Starter
    Addicted Member annie613's Avatar
    Join Date
    May 2003
    Location
    NY, NY
    Posts
    161

    date functions

    is there a way to add a date and time to a label
    or from a button click to a textArea

    like for instances

    Code:
    public void actionPerformed(ActionEvent e)
    {
    if(e.getSource()==btnDate)
    {
    jTextArea1.setText("Date and Time here!");
    Date();
    
    }//end btnDate
    any suggestions...
    thanks in advace

  2. #2

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Im not sure how you would want the date formatted.
    • SHORT is completely numeric, such as 12.13.52 or 3:30pm
    • MEDIUM is longer, such as Jan 12, 1952
    • LONG is longer, such as January 12, 1952 or 3:30:32pm
    • FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST.


    Code:
    import javax.swing.*; 
    import java.util.Date;
    import java.text.DateFormat;  
    
    DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
       
    JLabel jl = new JLabel(df.format(new Date()).toString());

  4. #4

    Thread Starter
    Addicted Member annie613's Avatar
    Join Date
    May 2003
    Location
    NY, NY
    Posts
    161
    excellent cheers!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width