| | |
| | | */ |
| | | @Override |
| | | public Date convert(String source) { |
| | | if(StringUtils.isNullOrEmpty(source)){ |
| | | throw new BusinessException(String.format("parser %s to Date fail", source)); |
| | | } |
| | | if("null".equals(source)){ |
| | | return null; |
| | | } |
| | | if(StringUtils.isNumericZidai(source)){ |
| | | return new Date(Long.parseLong(source)); |
| | | } |
| | | try { |
| | | return simpleDateFormat.parse(source); |
| | | if(StringUtils.isNullOrEmpty(source)){ |
| | | throw new BusinessException(String.format("parser %s to Date fail", source)); |
| | | } |
| | | if("null".equals(source)){ |
| | | return null; |
| | | } |
| | | if(StringUtils.isNumericZidai(source)) { |
| | | source = source.length() == 10 ? source+"000" : source; |
| | | return new Date(Long.parseLong(source)); |
| | | } else { |
| | | return simpleDateFormat.parse(source); |
| | | } |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | log.error(e.getMessage()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error(e.getMessage()); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |