Support Java Date when serializing update parameters, closes #1902.
This commit is contained in:
parent
40cd3c239e
commit
8e6d3753cc
|
@ -21,6 +21,7 @@ package org.elasticsearch.common.io.stream;
|
||||||
|
|
||||||
import org.elasticsearch.common.BytesHolder;
|
import org.elasticsearch.common.BytesHolder;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -280,6 +281,10 @@ public abstract class StreamInput extends InputStream {
|
||||||
return map;
|
return map;
|
||||||
} else if (type == 11) {
|
} else if (type == 11) {
|
||||||
return readByte();
|
return readByte();
|
||||||
|
} else if (type == 12) {
|
||||||
|
return new Date(readLong());
|
||||||
|
} else if (type == 13) {
|
||||||
|
return new DateTime(readLong());
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Can't read unknown type [" + type + "]");
|
throw new IOException("Can't read unknown type [" + type + "]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,11 @@ package org.elasticsearch.common.io.stream;
|
||||||
|
|
||||||
import org.elasticsearch.common.BytesHolder;
|
import org.elasticsearch.common.BytesHolder;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
|
import org.joda.time.ReadableInstant;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -262,6 +264,12 @@ public abstract class StreamOutput extends OutputStream {
|
||||||
} else if (type == Byte.class) {
|
} else if (type == Byte.class) {
|
||||||
writeByte((byte) 11);
|
writeByte((byte) 11);
|
||||||
writeByte((Byte) value);
|
writeByte((Byte) value);
|
||||||
|
} else if (type == Date.class) {
|
||||||
|
writeByte((byte) 12);
|
||||||
|
writeLong(((Date) value).getTime());
|
||||||
|
} else if (value instanceof ReadableInstant) {
|
||||||
|
writeByte((byte) 13);
|
||||||
|
writeLong(((ReadableInstant) value).getMillis());
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Can't write type [" + type + "]");
|
throw new IOException("Can't write type [" + type + "]");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue