01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.wfs.xml.xs;
06:
07: import org.geotools.xs.bindings.XSDateBinding;
08: import java.util.Calendar;
09: import java.util.Date;
10: import java.util.TimeZone;
11: import javax.xml.bind.DatatypeConverter;
12:
13: /**
14: * Override of binding for xs:date that forces date to be encoded in UTC
15: * timezone.
16: *
17: * @author Justin Deoliveira, The Open Planning Project
18: *
19: */
20: public class DateBinding extends XSDateBinding {
21: public String encode(Object object, String value) throws Exception {
22: Date date = (Date) object;
23: Calendar calendar = Calendar.getInstance();
24: calendar.setTime(date);
25: calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
26:
27: return DatatypeConverter.printDate(calendar);
28: }
29: }
|