Workshop: Watching the Clock

This hour's workshop gives you another look at each of the conditional tests you can use in your programs. For this project, you will use Java's built-in timekeeping feature, which keeps track of the current date and time, and present this information in sentence form.

Run the word processor you're using to create Java programs and give a new document the name This program is long, but most of it consists of long conditional statements. Type the full text of Listing 7.3 into the word processor and save the file as when you're done.

Listing 7.3. The ClockTalk Program
 1: import java.util.*; 2: 3: class ClockTalk { 4: public static void main(String[] arguments) { 5: // get current time ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.