UtilDateConverter.java
上传用户:kimgenplus
上传日期:2016-06-05
资源大小:20877k
文件大小:1k
源码类别:

OA系统

开发平台:

Java

  1. package com.bjsxt.oa.web;
  2. import java.text.ParseException;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Date;
  5. import org.apache.commons.beanutils.Converter;
  6. public class UtilDateConverter implements Converter {
  7. private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  8. public Object convert(Class type, Object value) {
  9. if (value == null) {
  10. return value;
  11. }
  12. if (value instanceof Date) {
  13. return value;
  14. }
  15. if (value instanceof String) {
  16. try {
  17. return format.parse((String)value);
  18. } catch (ParseException e) {
  19. e.printStackTrace();
  20. }
  21. }
  22. return null;
  23. }
  24. }