Orientdb 读出错误的时间
Orientdb reads out wrong time
我正在将 Orientdb 与 Eclipse 和 orientdb-client jar 一起使用。我使用以下语句来读出消息:
List<ODocument> result = connection.command(
new OSQLSynchQuery<ODocument>(
"SELECT * FROM Message"))
.execute();
乍一看结果是正确的,但后来我意识到我从DATTIME字段中读出的时间是错误的。
当我 运行 查询 "select * from Message " 时,locahost 版本给我以下结果(只是其中的一部分):
当我 运行 上面的 java 片段时,结果如下:
对于格式我使用了 SimpleDateFormat:
DateFormat formatter = new SimpleDateFormat("HH:mm:ss a");
String time = formatter.format(each.field("Time"));
那么为什么日期的小时不同(2 小时)?会不会是时区问题?
因为数据库 returns 导致数据库的时区。
您可以在 Db-> 配置部分的工作室中看到它。
更新时区的命令看起来像
alter database timezone GMT+6
我正在将 Orientdb 与 Eclipse 和 orientdb-client jar 一起使用。我使用以下语句来读出消息:
List<ODocument> result = connection.command(
new OSQLSynchQuery<ODocument>(
"SELECT * FROM Message"))
.execute();
乍一看结果是正确的,但后来我意识到我从DATTIME字段中读出的时间是错误的。
当我 运行 查询 "select * from Message " 时,locahost 版本给我以下结果(只是其中的一部分):
对于格式我使用了 SimpleDateFormat:
DateFormat formatter = new SimpleDateFormat("HH:mm:ss a");
String time = formatter.format(each.field("Time"));
那么为什么日期的小时不同(2 小时)?会不会是时区问题?
因为数据库 returns 导致数据库的时区。
您可以在 Db-> 配置部分的工作室中看到它。
更新时区的命令看起来像
alter database timezone GMT+6