title: convert a 4-digit military time into the standard 12 hour time format
body: <p><strong>What I'm trying to do:</strong></p>
  
  <p>I'm trying to convert a 4-digit military time into the standard 12 hour time format, with a colon and an added PM or AM without the use of importing anything before my code (I'm making a method that requires nothing other than java 101 techniques).</p>
  
  <p><strong>My situation:</strong></p>
  
  <p>I have <strong><em>milTime</em></strong>, which I manually change around for now every time I run it(as declared up top, currently at 1100), until I convert it into a method and submit the assignment, in which it will take in milTime, and will return milTimeString for the main program to print. I'm currently using BlueJ as an IDE, (I'm not sure if that's the best one to use?)</p>
  
  <p><strong>Example of input and output:</strong></p>
  
  <p>If 0056 were given, I would have to return 12:56am. 
  If 1125 were given, I would have to return 11:25am.
  If 2359 were given, I would have to return 11:59pm. </p>
  
  <p><strong>Issues I need help with</strong></p>
  
  <ol>
  <li>When I execute, my am / pm boolean fails somewhere and it always outputs pm, no matter if I input 11:24 or 23:24.</li>
  <li>It's probably obvious I'm working too hard to generate the output, but I don't know an easier way (Other than importing something to do it <em>for</em> me, which I don't want to do).</li>
  </ol>
  
  <p>I humbly submit to any criticism on my bloated current code, and any corrections in my long-winded request. I've looked around for alternate answers, and everything involved importing or knowledge beyond me. Thanks for your time so far, and thanks in advance everyone.</p>
  
  <pre><code>public class timeTest
  {
      public static void main(String []args)
      {   
          /*Declare my variables*/
          int milTime = 2400;
          String timeString = "";
          boolean pm;
  
          /*determine AM or PM and convert over 1200 into a clock's digits */
          if (milTime &gt;1259)
          {
              if (milTime &lt;1200)
              {
                  pm = false;
              }
              else
              {
                  pm = true;
              }
              milTime = (milTime - 1200);
          }
          else
          {
          }
  
          /*figure out my digits*/
          int fourthDigit = milTime%10;
          milTime = milTime/10;
          int thirdDigit = milTime%10;
          milTime = milTime/10;
          int secondDigit = milTime%10;
          milTime = milTime/10;
          int firstDigit = milTime%10;
  
          /*build each side of the colon*/
          String hoursString = thirdDigit + "" + fourthDigit;
          String minutesString = firstDigit + "" + secondDigit;
  
          /*determine if the first digit is zero and if so, omit it*/
          if (firstDigit == 0 )
          {
              minutesString = "" + secondDigit;
          }
          else
          {
          }
          if (secondDigit == 0)
          {
              minutesString = "12";
          }
          else
          {
          }
  
          /*build the total string and return the result with AM or PM based on conditional boolean.*/
          if (pm = true)
          {
              timeString = (minutesString + ':' + hoursString + "pm");
          }
          else
          {
          }
  
          if (pm = false)
          {
              timeString = (minutesString + ':' + hoursString + "am");
          }
          else
          {
          }
          System.out.println(timeString);
  
      }
  }
  </code></pre>