| Home | Links |

 Adding Date and Time

·         outputs the exact date and time that the program is run

·         note that the class imported is different from the ones you’ve seen in applets

·         its too complicated to be explained and you really don’t need to understand this

·         all you need to do is copy and paste it into your code

import java.util.*;
import java.text.*;
public class Now String
{

public static void main (String[] args)
{

Date now = new Date ();
DateFormat df = DateFormat.getDateInstance ();
String s = df.format (now);
System.out.println ("Today is " + s);

}

}