title: How to convert date format 2017-02-08 00:00:00.0 to 08/02/2017 in java?
body: <p>I want to convert Date format from 2017-02-08 00:00:00.0 to dd/MM/yyyy(08/02/2017). I tried with the following code.</p>
  
  <pre><code>          String dateInString  =bean.getDate();
            Date date = null;
            SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
  
            if (bean.getDate().matches("^[0-9]{2,4}(-[0-9]{1,2}){2}\\s[0-9]{1,2}(:[0-9]{1,2}){2}\\.[0-9]{1,}$")) {
                  try {
                      date = formatter.parse(dateInString);
                  } catch (ParseException e) {
                      e.printStackTrace();
                  }
            } 
  </code></pre>
  
  <p>But I am getting NullPointerException in <code>date = formatter.parse(dateInString);</code> line.</p>