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.wfsv.response.v1_1_0;
06:
07: import java.text.SimpleDateFormat;
08: import java.util.Date;
09:
10: /**
11: * A subclass of FeatureWrapper that outputs a ISO8601 compliant date string.
12: *
13: * @author Arne Kepp, The Open Planning Project
14: *
15: */
16: public class FeatureISODateWrapper extends
17: org.geoserver.template.FeatureWrapper {
18:
19: private static SimpleDateFormat sdf = new SimpleDateFormat(
20: "yyyy-MM-dd'T'HH:mm:ss");
21:
22: /**
23: * Wraps dates as ISO date strings; defaults to the superclass for other kind of objects.
24: *
25: * @param o could be an instance of Date (a special case)
26: * @return the formated date as a String, or the value returned by the overriden method in the superclass.
27: */
28: protected String wrapValue(Object o) {
29: if (o instanceof Date) {
30: return sdf.format((Date) o);
31: } else {
32: return super.wrapValue(o);
33: }
34: }
35: }
|