public void print() {
        int printableHour; // hour value to be printed
        String amPm; // am or pm value to be printed

        if (error != null) {
            System.out.println(error);
        } else {
            // convert 24h to 12 h
            amPm = hour >= 12 ? "PM" : "AM"; // am or pm value to be printed
            if (hour > 12) {
                printableHour = hour - 12;
            } else if (hour == 0) {
                printableHour = 12;
            } else {
                printableHour = hour;
            }
            System.out.printf("%1$02d:%2$02d %3$s%n", printableHour, minute, amPm);
        }
    }