diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java index 2680aa70b57..9634736cbeb 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java @@ -48,6 +48,7 @@ import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.warmer.IndexWarmersMetaData; import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; import java.io.IOException; import java.text.ParseException; @@ -940,7 +941,7 @@ public class IndexMetaData implements Diffable { } Long creationDate = settings.getAsLong(SETTING_CREATION_DATE, null); if (creationDate != null) { - DateTime creationDateTime = new DateTime(creationDate); + DateTime creationDateTime = new DateTime(creationDate, DateTimeZone.UTC); builder.put(SETTING_CREATION_DATE_STRING, creationDateTime.toString()); } return builder.build(); diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java index f8e809e9a55..b53e218f216 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java @@ -63,6 +63,8 @@ import org.elasticsearch.index.IndexService; import org.elasticsearch.indices.*; import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.ThreadPool; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; import java.io.BufferedReader; import java.io.IOException; @@ -325,7 +327,7 @@ public class MetaDataCreateIndexService extends AbstractComponent { } if (indexSettingsBuilder.get(SETTING_CREATION_DATE) == null) { - indexSettingsBuilder.put(SETTING_CREATION_DATE, System.currentTimeMillis()); + indexSettingsBuilder.put(SETTING_CREATION_DATE, new DateTime(DateTimeZone.UTC).getMillis()); } indexSettingsBuilder.put(SETTING_UUID, Strings.randomBase64UUID()); diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/HumanReadableIndexSettingsTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/HumanReadableIndexSettingsTests.java index 7aa4cc5a67d..5a5ee4d311e 100644 --- a/core/src/test/java/org/elasticsearch/cluster/metadata/HumanReadableIndexSettingsTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/metadata/HumanReadableIndexSettingsTests.java @@ -23,6 +23,7 @@ import org.elasticsearch.Version; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ElasticsearchTestCase; import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; import org.junit.Test; import static com.google.common.collect.Sets.newHashSet; @@ -45,6 +46,6 @@ public class HumanReadableIndexSettingsTests extends ElasticsearchTestCase { assertEquals(versionCreated.toString(), humanSettings.get(IndexMetaData.SETTING_VERSION_CREATED_STRING, null)); assertEquals(versionUpgraded.toString(), humanSettings.get(IndexMetaData.SETTING_VERSION_UPGRADED_STRING, null)); - assertEquals(new DateTime(created).toString(), humanSettings.get(IndexMetaData.SETTING_CREATION_DATE_STRING, null)); + assertEquals(new DateTime(created, DateTimeZone.UTC).toString(), humanSettings.get(IndexMetaData.SETTING_CREATION_DATE_STRING, null)); } }