-
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 :)
-
Code:
JLabel jl = new JLabel(new Date().toString());
-
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());
-