title: How do I trim a string to parse a time with a SimpleDateFormat in java?
body: <p>I'm trying to input a string with a mix of characters and have some bit of code remove all but the part that matches the desired SimpleDateFormat</p>
  <pre><code>String wholeString = new String(&quot;The time is 7:00.&quot;);
  String timeOnlyString = CODE TO TRIM STRING;
  SimpleDateFormat sdf = new SimpleDateFormat(&quot;HH:mm&quot;);
  Date timeAsObject = sdf.parse(timeOnlyString);
  String timeAsString = sdf.format(timeAsObject);
  System.out.println(timeAsString);`
  </code></pre>
  <p>With this code I'd like</p>
  <blockquote>
  <p>07:00</p>
  </blockquote>
  <p>Printed in the console.</p>