Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timezone for @RowKey griddb index #252

Open
harshajayaweeraXHJ opened this issue Mar 3, 2020 · 2 comments
Open

Timezone for @RowKey griddb index #252

harshajayaweeraXHJ opened this issue Mar 3, 2020 · 2 comments

Comments

@harshajayaweeraXHJ
Copy link

I'm using

@RowKey
  Date originTimestamp;

As the timestamp format for my time series container. is it possible to store this as a Long epoch and use epoch value when performing sampling query TIMESTAMP('" + longEpoch + "') instead of string format('2004-02-05T10:15:30.000Z').

The reason is I need to use UTC epoch format when working with time so it is less confusing and less error prone.

Also when i store data as Date originTimestamp which time zone does it use in the database

@knonomura
Copy link
Member

Thank you for your question.

We must use the row key column for time series container with Date type on Java.

How about the following method ?

Date now = new Date();
Date before = TimestampUtils.add(now, -6, TimeUnit.HOUR);
long epochNow = now.getTime(); // The unit is milliseconds.
long epochBefore = before.getTime(); // The unit is milliseconds.

String tql = "select * where originTimestamp > TO_TIMESTAMP_MS(" + epochBefore + ") and originTimestamp < TO_TIMESTAMP_MS(" + epochNow + ")");

http://griddb.org/griddb_nosql/manual/GridDB_API_Reference.html#sec-3-2-7
3.2.7 Time-Type Operations

And basic datatype "TIMESTAMP" for GridDB means UTC. Accuracy is in milliseconds.
http://griddb.org/griddb_nosql/manual/GridDB_API_Reference.html#sec-7-1

@harshajayaweeraXHJ
Copy link
Author

Thank you very much. I didn't know such a format (... originTimestamp > TO_TIMESTAMP_MS(1583305036) ...) is possible. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants