1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package examples.jodatime;
18
19 import java.util.Date;
20
21 import org.joda.time.DateTime;
22 import org.joda.time.DateTimeZone;
23 import org.yaml.snakeyaml.constructor.Constructor;
24 import org.yaml.snakeyaml.nodes.Node;
25 import org.yaml.snakeyaml.nodes.Tag;
26
27 public class JodaTimeContructor extends Constructor {
28 public JodaTimeContructor() {
29 this.yamlConstructors.put(Tag.TIMESTAMP, new ConstructJodaTimestamp());
30 }
31
32 private class ConstructJodaTimestamp extends ConstructYamlTimestamp {
33 public Object construct(Node node) {
34 Date date = (Date) super.construct(node);
35 return new DateTime(date, DateTimeZone.UTC);
36 }
37 }
38 }