Filipe Miranda Filipe Miranda - 6 months ago 31
Java Question

What is The Z at the end of Date in Elasticsearch

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?

Answer

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,

Rhys