Why in Elasticsearch we have the 'Z' at the end of the date field?
For instance:
2016-05-16T00:00:00.000Z
What does it mean?
Is this something useful for anything?
Is it harmful?
Can I get rid of it?
What about joda time?
Why in Elasticsearch we have the 'Z' at the end of the date field?
For instance:
2016-05-16T00:00:00.000Z
What does it mean?
Is this something useful for anything?
Is it harmful?
Can I get rid of it?
What about joda time?
What does it mean?
The 'Z' means UTC.
Reference:
https://www.w3.org/TR/NOTE-datetime
Try not to store local dates. If you want to find a good thread on dates and why you should use UTC check this thread.
Is this something useful for anything?
It is very useful, storing all dates in UTC allows for easy conversion of dates from locale to locale. It also allows for date comparison and date visualisations to be consistent.
Is it harmful?
No.
Can I get rid of it?
If you wish? I wouldn't recommend doing it... It's a bit like removing the currency field from a transaction. The transaction doesn't make any sense.
Another example with dates:
I rang my friend in Country X (+6 hours ahead) at 1pm December 24th 2016. For him it was 7pm. So we have two local date times.
One for me:
1pm December 24th 2016 in London
One for my friend:
7pm December 24th 2016 in Country X
If I delete the 'in ...' Part these two become become two instances of time 5 hours apart of each other. Which means we couldn't have possibly spoken on the phone? Right?
No, because they are the same instance in time, across two locales.
What about joda time?
What about it?...
I hope this helps.
From RFC3339 about Date and Time on the Internet:
Numeric offsets are calculated as "local time minus UTC". So the equivalent time in UTC can be determined by subtracting the offset from the local time. For example, 18:50:00-04:00 is the same time as 22:50:00Z. (This example shows negative offsets handled by adding the absolute value of the offset.)
So, a date with Z
at the end is the date&time in UTC. And it should be the equivalent of 2016-05-16T00:00:00.000Z-00:00
.
The presence of the timezone offset or not is just a matter of the date format being used in Elasticsearch's field definition.