Don't know if you've solved this one, but incase it can help someone else here is a basic solution.
I'm assuming you wanted the date formated MM/dd/yy.. new Date().toString() will give you the date in long format if you want to cut the code down even further i.e. October 20, 2004 10:49PM EST etc....
import javax.swing.*;
import java.util.*;
import java.text.*;
public class OptionPaneTest
{
public static void main(String[] args)
{
SimpleDateFormat dateFormat = new SimpleDateFormat ( "MM/dd/yy" );
String dateToday = dateFormat.format( new Date() );
String name = JOptionPane.showInputDialog(null, "What is your name?" );
JOptionPane.showMessageDialog(null, name + " " + dateToday);
}
}
Last edited by skitz0; 10-19-2004 at 11:07 PM..
|