Okay so I have a clock class which is initially set as a 24 hour clock but I have to have the clock display as a 12 hour clock using only this method! I have tried for hours but have fallen short! Please help. Make the clock display the time as a 12 hour clock (hh:mm:ss AM/PM). Use abstraction - don’t change anything but the updateDisplay() method. The clock can use military time "under the covers"; it just needs to return the proper string when getTime() is called.
private void updateDisplay()
{
String AM = "AM";
String PM = "PM";
if(hours.getValue() == 0) {
hours.setValue(hours.getValue() + 12);
PM = "";
}
else if(hours.getValue() == 1 < hours.getValue() && hours.getValue() < 11) {
PM = "";
}
else if(hours.getValue() == 12) {
AM = "";
}
else if(hours.getValue() == 13 > 24) {
hours.setValue(hours.getValue() - 12);
AM = "";
}
displayString = hours.getDisplayValue() + ":" +
minutes.getDisplayValue() + ":" +
seconds.getDisplayValue() + PM + AM;
}