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
.jaxb
;
12 import javax
.xml
.bind
.annotation
.adapters
.XmlAdapter
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.joda
.time
.DateTime
;
16 import org
.joda
.time
.format
.DateTimeFormatter
;
17 import org
.joda
.time
.format
.ISODateTimeFormat
;
24 public class DateTimeAdapter
extends XmlAdapter
<String
, DateTime
> {
25 private static final Logger logger
= Logger
.getLogger(DateTimeAdapter
.class);
28 public String
marshal(DateTime dateTime
) throws Exception
{
29 if (logger
.isDebugEnabled()){logger
.debug("marshal");}
30 if(dateTime
== null) {
33 DateTimeFormatter dateTimeFormatter
= ISODateTimeFormat
.dateTime();
34 return dateTimeFormatter
.print(dateTime
);
39 public DateTime
unmarshal(String value
) throws Exception
{
40 if (logger
.isDebugEnabled()){logger
.debug("unmarshal");}
41 return ISODateTimeFormat
.dateTimeParser().parseDateTime(value
);