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.jaxb;
|
11
|
|
12
|
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
13
|
|
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;
|
18
|
|
19
|
/**
|
20
|
* @author a.mueller
|
21
|
* @created 23.07.2008
|
22
|
* @version 1.0
|
23
|
*/
|
24
|
public class DateTimeAdapter extends XmlAdapter<String, DateTime> {
|
25
|
private static final Logger logger = Logger.getLogger(DateTimeAdapter.class);
|
26
|
|
27
|
@Override
|
28
|
public String marshal(DateTime dateTime) throws Exception {
|
29
|
DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime();
|
30
|
return dateTimeFormatter.print(dateTime);
|
31
|
}
|
32
|
|
33
|
@Override
|
34
|
public DateTime unmarshal(String value) throws Exception {
|
35
|
return ISODateTimeFormat.dateTimeParser().parseDateTime(value);
|
36
|
}
|
37
|
}
|