title: Can I use a DateComponentsFormatter to render the time of day?
body: <p>I would like to store a time of day in a simple way. For the purposes of my app, I only care about a specific time of day, like 2:30pm or 1:10am.</p>
  <p>Using a <code>DateComponentsFormatter</code> I can get really close.</p>
  <pre><code>import Foundation
  
  let formatter = DateComponentsFormatter()
  formatter.unitsStyle = .positional
  formatter.allowedUnits = [
      .hour,
      .minute
  ]
   
  // Use the configured formatter to generate the string.
  let timeAmount = 9000.0
  let outputString = formatter.string(from: timeAmount)
  let desiredString = &quot;2:30 pm&quot;import Foundation
  
  let formatter = DateComponentsFormatter()
  formatter.unitsStyle = .positional
  formatter.allowedUnits = [
      .hour,
      .minute
  ]
   
  // Use the configured formatter to generate the string.
  let timeAmount = 9000.0
  let outputString = formatter.string(from: timeAmount) // yields &quot;2:30&quot;
  let desiredString = &quot;2:30 pm&quot;
  </code></pre>
  <p>Now, it seems that the formatter is really just saying &quot;two hours and thirty minutes,&quot; so maybe I am barking up the wrong tree here. Does <code>DateComponentsFormatter</code> support my use case?</p>