title: How do I convert date formatted string timestamp into date?
body: <p>I need to convert the current timestamp and current minus 1-minute timestamp into a given format. I was able to convert the desired format. But it was returning as String.</p>
  <p>I need the formatted output as Date instead of String.</p>
  <pre><code>public static void main(String[] args) throws ParseException
  {
      SimpleDateFormat dateFormatter = new SimpleDateFormat(&quot;yyyy-MM-dd HH:mm:00&quot;);
      long now = System.currentTimeMillis();
      String toTimeStamp = dateFormatter.format(now);
      long nowMinus1Minutes = now - TimeUnit.MINUTES.toMillis(1);
      String fromTimeStamp = dateFormatter.format(nowMinus1Minutes);
      System.out.println(fromTimeStamp);
      System.out.println(toTimeStamp);
  
      // Tried with parse
      Date fromDate = dateFormatter.parse(fromTimeStamp);
      Date toDate = dateFormatter.parse(toTimeStamp);
  
      System.out.println(fromDate);
      System.out.println(toDate);
  
  }
  
  Output:(String)
  
  2020-07-24 12:13:00 
  2020-07-24 12:12:00
  
  Output: Pose Parsed the string as Date
  
  Fri Jul 24 12:16:00 IST 2020
  Fri Jul 24 12:17:00 IST 2020
  </code></pre>
  <p><strong><strong>Expected Output:</strong></strong></p>
  <pre><code>2020-07-24 12:13:00 (As Date Object)
  2020-07-24 12:12:00 (As Date Object)
  </code></pre>