forked from jankotek/mapdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateSerializer.java
More file actions
50 lines (39 loc) · 1.01 KB
/
Copy pathDateSerializer.java
File metadata and controls
50 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package org.mapdb.ser;
import org.jetbrains.annotations.Nullable;
import org.mapdb.io.DataInput2;
import org.mapdb.io.DataOutput2;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
/**
* Created by jan on 2/28/16.
*/
public class DateSerializer extends EightByteSerializer<Date> {
@Override
public void serialize(DataOutput2 out, Date value) {
out.writeLong(value.getTime());
}
@Override
public Date deserialize(DataInput2 in) {
return new Date(in.readLong());
}
@Nullable
@Override
public Class serializedType() {
return Date.class;
}
@Override
protected Date unpack(long l) {
return new Date(l);
}
@Override
protected long pack(Date l) {
return l.getTime();
}
@Override
final public int valueArraySearch(long[] keys, Date key) {
//TODO valueArraySearch versus comparator test
long time = key.getTime();
return Arrays.binarySearch((long[])keys, time);
}
}