Use UTC as timeszone for index creation date
This commit is contained in:
parent
2a63249441
commit
85dccdb8ab
|
@ -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<IndexMetaData> {
|
|||
}
|
||||
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();
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue