2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.remote
.json
.processor
.value
;
12 import java
.text
.SimpleDateFormat
;
13 import java
.util
.Calendar
;
15 import net
.sf
.json
.JsonConfig
;
16 import net
.sf
.json
.processors
.JsonValueProcessor
;
18 import org
.apache
.logging
.log4j
.LogManager
;import org
.apache
.logging
.log4j
.Logger
;
23 * @author a.kohlbecker
27 public class CalendarJSONValueProcessor
implements JsonValueProcessor
{
28 private static Logger logger
= LogManager
.getLogger(DateTimeJSONValueProcessor
.class);
30 private static SimpleDateFormat iso8601Format
= new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");
33 * @see net.sf.json.processors.JsonValueProcessor#processArrayValue(java.lang.Object, net.sf.json.JsonConfig)
35 public Object
processArrayValue(Object object
, JsonConfig jsonConfig
) {
39 Calendar calendar
= (Calendar
) object
;
40 if (logger
.isDebugEnabled()) {
41 logger
.debug("processArrayValue of java.util.Calendar: " + CalendarJSONValueProcessor
.iso8601Format
.format(calendar
.getTime()));
43 return CalendarJSONValueProcessor
.iso8601Format
.format(calendar
.getTime());
47 * @see net.sf.json.processors.JsonValueProcessor#processObjectValue(java.lang.String, java.lang.Object, net.sf.json.JsonConfig)
49 public Object
processObjectValue(String key
, Object object
, JsonConfig jsonConfig
) {
53 Calendar dateTime
= (Calendar
) object
;
54 if (logger
.isDebugEnabled()) {
55 logger
.debug("processObjectValue of java.util.Calendar: " + CalendarJSONValueProcessor
.iso8601Format
.format(dateTime
.getTime()));
57 return CalendarJSONValueProcessor
.iso8601Format
.format(dateTime
.getTime());