title: Converting 24-hour clock time to am/pm in Joda-Time
body: <p>I just started working with <a href="http://www.joda.org/joda-time/" rel="noreferrer">Joda-Time</a>, and got it to correctly display my date in <a href="https://en.wikipedia.org/wiki/24-hour_clock" rel="noreferrer">24-hour clock</a> ("military time") but I would rather it be am/pm.  Looked it up and it mentioned <a href="http://joda-time.sourceforge.net/apidocs/org/joda/time/DateTime.html#hourOfDay%28%29" rel="noreferrer">hourOfDay</a> which I figured was the HH value so I tried to write a loop that would break it down into AM/Pm but it never worked out.   </p>
  
  <pre><code>    DateTime dtf = new DateTime(wikiParsedDate);
  
  
      if (hourOfDay == 00) {
          hourOfDay == 12;
          DateTimeFormatter builder = DateTimeFormat.forPattern( "dd-MM-yyyy HH:mm:ss.SS'AM" );
          return builder.print(dtf);
      } else if (0 &lt; hourOfDay &amp;&amp; hourOfDay &lt; 12) {
          DateTimeFormatter builder = DateTimeFormat.forPattern( "dd-MM-yyyy HH:mm:ss.SS'AM" );
          return builder.print(dtf);
      } else if (hourOfDay &gt; 12) {
          hourOfDay - 12 == hourOfDay;
          DateTimeFormatter builder = DateTimeFormat.forPattern( "dd-MM-yyyy HH:mm:ss.SS'PM" );
          return builder.print(dtf);
      }
  
  }
  </code></pre>