title: Date difference in different timezones in java
body: <p>I am pragmatically building a nested JSON from a table. Json looks something like this:</p>
  
  <pre><code>{"date":"03-16-2018 06:57:02",
   "details":
      [  
          {  
             "motorstate":0,
             "startTime":"03-16-2018 20:41:57",               
          },
          {  
             "motorstate":0,
             "startTime":"03-16-2018 06:57:02",               
          }
       ]
  },
  {"date":"03-15-2018 08:08:48",
  "details":
     [  
          {  
             "motorstate":0,
             "startTime":"03-16-2018 03:53:30",
          }
     ]
  }
  </code></pre>
  
  <p>If you look into the above example, the second record:</p>
  
  <pre><code>{"date":"03-15-2018 08:08:48",
  "details":
     [  
          {  
             "motorstate":0,
             "startTime":"03-16-2018 03:53:30",
          }
     ]
  }
  </code></pre>
  
  <p>The dates are mismatching. This is because the date shown here is in IST but actually stored in UTC in my Google Datastore. In UTC, its still 03-15-2018 and not 03-16-2018.</p>
  
  <p>My question is how can we perform a date difference in different timezones other than UTC in Java? The Date.getTime() method always give the difference in UTC and not in local Timezone.</p>