title: Java Converting String to Date resulting one day less even though browser time zone provided
body: <p>I'm sending date from the Angular app as String to server and converting to java <code>Date</code> object to store in the database.</p>
  
  <p>Also sending <code>timeZoneOffset</code> from UI to use the client's time zone while converting. (After googling I found this approach to get the proper result based on the user location)</p>
  
  <p>Written the following code to convert:</p>
  
  <pre><code>public static void main(String args[]) throws ParseException {
      String inputDate = "04/05/2018"; // This date coming from UI
      int timeZoneOffset = -330; // This offset coming from UI 
                                 // (new Date().getTimeZoneOffset())
      getDate(inputDate, timeZoneOffset);
  }
  
  public static Date getDate(String inputDate, int timeZoneOffset)
          throws ParseException {
      SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
      ZoneOffset zoneOffset = ZoneOffset.ofTotalSeconds(-timeZoneOffset * 60);
      System.out.println("Default time zone: " + TimeZone.getDefault().getID());
      TimeZone timeZone = TimeZone.getTimeZone(zoneOffset);
      System.out.println("Time zone from offset: " + timeZone.getID());
      dateFormat.setTimeZone(timeZone);
      Date date = dateFormat.parse(inputDate);
      System.out.println("Converted date: " + date);
      return date;
  }
  </code></pre>
  
  <p><strong>Expected output</strong>:</p>
  
  <blockquote>
    <p>Default time zone: America/New_York<br>
        Time zone from offset: GMT+05:30<br>
        Converted date: Thu April 5 00:00:00 IST 2018</p>
  </blockquote>
  
  <p><strong>Actual result in server</strong>: </p>
  
  <blockquote>
    <p>Default time zone: America/New_York<br>
        Time zone from offset: GMT+05:30<br>
        Converted date: Wed April 4 14:30:00 EDT 2018</p>
  </blockquote>
  
  <p>Why is the date decreasing to one day even I set the users time zone? I'm new to Date and Time related concepts and I googled a couple of times didn't find answer, could someone please help on this.</p>
  
  <p>Thanks in advance</p>