package Test; import flexjson.*; import flexjson.transformer.*; import flexjson.ObjectBinder; import flexjson.JSONException; import flexjson.ObjectFactory; import java.text.SimpleDateFormat; import java.text.ParseException; import java.lang.reflect.Type; public class DateTransformer extends AbstractTransformer implements ObjectFactory { SimpleDateFormat simpleDateFormatter; public DateTransformer(String dateFormat) { simpleDateFormatter = new SimpleDateFormat(dateFormat); } public void transform(Object value) { getContext().writeQuoted(simpleDateFormatter.format(value)); } public Object instantiate(ObjectBinder context, Object value, Type targetType, Class targetClass) { try { return simpleDateFormatter.parse( value.toString() ); } catch (ParseException e) { //throw new JSONException(String.format( "Failed to parse %s with %s pattern.", value, simpleDateFormatter.toPattern() ), e ); return value; } } }

wusiyin LV14
2022年9月15日
askeydingxu2020 LV8
2020年11月28日
skipple3 LV39
2020年11月19日
xcj456 LV8
2020年9月12日
hzhsh0223 LV18
2020年3月7日
yfsh123 LV6
2019年8月9日
y_yuyongyi LV1
2019年8月7日
wanglong_wang LV13
2019年8月1日
zbchen2008 LV6
2019年7月9日
丷夏空丷 LV4
2019年5月19日