01: /*
02: * Copyright (C) 2004, 2005 Joe Walnes.
03: * Copyright (C) 2006, 2007 XStream Committers.
04: * All rights reserved.
05: *
06: * The software in this package is published under the terms of the BSD
07: * style license a copy of which has been included with this distribution in
08: * the LICENSE.txt file.
09: *
10: * Created on 22. November 2004 by Mauro Talevi
11: */
12: package com.thoughtworks.xstream.converters.extended;
13:
14: import java.util.Calendar;
15: import java.util.Date;
16:
17: /**
18: * A DateConverter conforming to the ISO8601 standard.
19: * http://www.iso.ch/iso/en/CatalogueDetailPage.CatalogueDetail?CSNUMBER=26780
20: *
21: * @author Mauro Talevi
22: * @author Jörg Schaible
23: */
24: public class ISO8601DateConverter extends
25: ISO8601GregorianCalendarConverter {
26:
27: public boolean canConvert(Class type) {
28: return type.equals(Date.class);
29: }
30:
31: public Object fromString(String str) {
32: return ((Calendar) super .fromString(str)).getTime();
33: }
34:
35: public String toString(Object obj) {
36: Calendar calendar = Calendar.getInstance();
37: calendar.setTime((Date) obj);
38: return super.toString(calendar);
39: }
40: }
|