title: Convert java.util.Date to different time zone requested
body: <p>Depending on a request url, I have to convert a Date to different requested time zone and return date and time as String. I am using java 8 with spring boot and mongo 3.2</p>
  
  <p>So inside the service method, I first set the time zone as below,</p>
  
  <pre><code>TimeZone.setDefault(TimeZone.getTimeZone(TIME_ZONE))
  </code></pre>
  
  <p>But I notice, it will change the time zone of whole java application. So even the method exit, the time zone would be remain the time zone I set previously.</p>
  
  <p>So instead <code>setDefault</code> method level, I set it specifically in the <code>SimpleDateFormat</code> as below,</p>
  
  <p>(assignment is a Assignmet document class having <code>java.util.Date</code> as a property named assignmentEndDate which map to a mongodb collection. In mongo db assignmentEndDate is store as UTC)</p>
  
  <pre><code>   java.text.DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy'T'HH:mm:ss.SSS");
     formatter.setTimeZone(TimeZone.getTimeZone(timezone));
     Date assignmentEndDate = assignment.getAssignmentEndDate();
     formatter.format(assignmentEndDate);
  </code></pre>
  
  <p>This way it wont change the application level time zone. Is this the correct approach for such scenario?</p>