1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.remote.json.processor.value;
|
11
|
|
12
|
import net.sf.json.JsonConfig;
|
13
|
import net.sf.json.processors.JsonValueProcessor;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.joda.time.DateTime;
|
17
|
import org.joda.time.format.DateTimeFormatter;
|
18
|
import org.joda.time.format.ISODateTimeFormat;
|
19
|
|
20
|
/**
|
21
|
* @author n.hoffmann
|
22
|
* @since 24.07.2008
|
23
|
* @version 1.0
|
24
|
*/
|
25
|
public class DateTimeJSONValueProcessor implements JsonValueProcessor {
|
26
|
private static Logger logger = Logger
|
27
|
.getLogger(DateTimeJSONValueProcessor.class);
|
28
|
|
29
|
private static DateTimeFormatter iso8601Format = ISODateTimeFormat.dateTime();
|
30
|
|
31
|
/* (non-Javadoc)
|
32
|
* @see net.sf.json.processors.JsonValueProcessor#processArrayValue(java.lang.Object, net.sf.json.JsonConfig)
|
33
|
*/
|
34
|
public Object processArrayValue(Object object, JsonConfig jsonConfig) {
|
35
|
DateTime dateTime = (DateTime) object;
|
36
|
return DateTimeJSONValueProcessor.iso8601Format.print(dateTime);
|
37
|
}
|
38
|
|
39
|
/* (non-Javadoc)
|
40
|
* @see net.sf.json.processors.JsonValueProcessor#processObjectValue(java.lang.String, java.lang.Object, net.sf.json.JsonConfig)
|
41
|
*/
|
42
|
public Object processObjectValue(String key, Object object,
|
43
|
JsonConfig jsonConfig) {
|
44
|
DateTime dateTime = (DateTime) object;
|
45
|
return DateTimeJSONValueProcessor.iso8601Format.print(dateTime);
|
46
|
}
|
47
|
}
|