timetype.java
来自「Xfire文件 用于开发web service 的一个开源工具 很好用的」· Java 代码 · 共 48 行
JAVA
48 行
package org.codehaus.xfire.aegis.type.basic;import java.sql.Time;import java.text.ParseException;import java.util.Calendar;import org.codehaus.xfire.MessageContext;import org.codehaus.xfire.aegis.MessageReader;import org.codehaus.xfire.aegis.MessageWriter;import org.codehaus.xfire.aegis.type.Type;import org.codehaus.xfire.fault.XFireFault;import org.codehaus.xfire.util.date.XsTimeFormat;/** * Type for the Time class which serializes to an xs:time. * * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a> */public class TimeType extends Type{ private static XsTimeFormat format = new XsTimeFormat(); public Object readObject(MessageReader reader, MessageContext context) throws XFireFault { String value = reader.getValue(); if (value == null) return null; try { Calendar c = (Calendar) format.parseObject(value); return new Time(c.getTimeInMillis()); } catch (ParseException e) { throw new XFireFault("Could not parse xs:dateTime: " + e.getMessage(), e, XFireFault.SENDER); } } public void writeObject(Object object, MessageWriter writer, MessageContext context) { Calendar c = Calendar.getInstance(); c.setTime((Time) object); writer.writeValue(format.format(c)); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?