← Back to Week 3 Hub
Workbook 3a — Exercise

Format Dates

Take today's date and time and show it in several different human-readable formats  |  Workbook p.33

The Exercise

Create a Java application called format-dates. The program grabs the current date and time, then prints it to the screen five different ways. There's one output per format — one line each, all printed in a single run of the program.

Display the current date and time in each of these formats:

Challenge: Add one more line that shows the time and date in your local time zone using the format 5:02 on 22-Apr-2026.

Example Run
Run — Today (Apr 22, 2026)
04/22/2026
10:02 display in GMT time
2026-04-22
Wednesday 22, 2026
Wednesday, Apr 22, 2026
5:02 on 22-Apr-2026
Concepts You'll Use
Flow
1. LocalDateTime.now()
2. "MM/dd/yyyy"
3. "HH:mm" (GMT)
4. "yyyy-MM-dd"
5. "EEEE dd, yyyy"
6. "EEEE, MMM dd, yyyy"
7. Challenge: "h:mm 'on' dd-MMM-yyyy"

Workbook 3a, p.33 — Exercise: Format Dates

← Payroll Calculator (Write) Search Engine Logger →