• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to change a 24 hour clock to a 12 hour clock in bluej

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to change a 24 hour clock to a 12 hour clock. I have the majority of it done but I cant get midnight to change from 00:00 to 12:00. Here is my code that i have. The method updateDisplayUS is the 12 hour clock.
public class ClockDisplay

 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

You need to add both halves of the code tags for your code to look good. I have sorted it out for you this time Your indentation is inconsistent. You should use automatic indentation and change tab→4 spaces. I think BlueJ will do that automatically. And that is about the only good thing I have said about BlueJ for years

Write down how you intend to convert the numbers to 12‑hour format. It is quite simple, if you remember the five arithmetical operators (actually there are about 18 operators you can use for arithmetic) to convert 15 or 3 to 3 and remember there is another operator which will allow you to choose "pm" or "am" easily.
Then all you have to do is work out how to get 12:00am (which is not actually correct; it should be 12:00midnight) from 00:00
 
reply
    Bookmark Topic Watch Topic
  • New Topic