Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • Cleanest solution. THX! Commented Nov 29, 2016 at 10:29
  • But that's not a clean solution to send dates, because TimeStamps are always UTC. Best solution for me when sending dates, is to use a string representation like "dd/MM/yyyy HH:mm:ss" and then parse it on server side with server's default TimeZone to get an UTC timestamp or whatever. See this answer Commented Jul 10, 2018 at 17:59
  • 2
    parsing a string - you're calling that clean? meh Commented Jul 13, 2018 at 22:53
  • Be sure, there are methods to generate a date in string format according to ISO specifications. The method is toISOString(). You can parse it cleanly in Java using something like: DateTime dt = new DateTime ("2018-07-15T02:36:00+02:00"); Commented Jul 15, 2018 at 0:42
  • 1
    Another wrong answer, this.getTime() returns a UTC offset, subtracting the local timezone offset makes it local, not UTC so getUTCTime returns a local offset, not UTC. Commented Apr 7, 2020 at 8:12