View Single Post
Old 10-19-2004, 11:01 PM   #9 (permalink)
skitz0
Upright
 
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..
skitz0 is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62