KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > TimeZoneConverter


1
2
3 import org.jdom.Attribute;
4 import org.swixml.Converter;
5 import org.swixml.Localizer;
6
7 import java.util.SimpleTimeZone JavaDoc;
8
9
10 public class TimeZoneConverter implements Converter {
11   /**
12    * Convert the value of the given <code>Attribute</code> object into an output object of the
13    * specified type.
14    *
15    * @param type <code>Class</code> Data type to which the Attribute's value should be converted
16    * @param attr <code>Attribute</code> the attribute, providing the value to be converted.
17    *
18    */

19   public Object JavaDoc convert(Class JavaDoc type, Attribute attr, Localizer lz) throws Exception JavaDoc {
20     SimpleTimeZone JavaDoc tz = null;
21     if (attr != null && attr.getValue() != null) {
22       tz = new SimpleTimeZone JavaDoc( 0, attr.getValue() );
23     }
24     return tz;
25   }
26
27   /**
28    * A <code>Converters</code> conversTo method informs about the Class type the converter
29    * is returning when its <code>convert</code> method is called
30    * @return <code>Class</code> - the Class the converter is returning when its convert method is called
31    */

32   public Class JavaDoc convertsTo() {
33     return SimpleTimeZone JavaDoc.class;
34   }
35 }
36
Popular Tags