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 ClockTalk.java. 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 ClockTalk.java 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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.