DateUtil.java 727 B

123456789101112131415161718192021222324252627282930313233
  1. package com.xintong.visualinspection.util;
  2. import java.text.ParseException;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Date;
  5. public class DateUtil {
  6. /**
  7. * string date parse Date
  8. * @param strDate
  9. * @return Date (Exception null)
  10. */
  11. public static Date strParseDate(String strDate){
  12. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );
  13. try {
  14. return sdf.parse(strDate);
  15. } catch (ParseException e) {
  16. e.printStackTrace();
  17. }
  18. return null;
  19. }
  20. public static Date strParseDate(String strDate,String format){
  21. SimpleDateFormat sdf = new SimpleDateFormat(format);
  22. try {
  23. return sdf.parse(strDate);
  24. } catch (ParseException e) {
  25. e.printStackTrace();
  26. }
  27. return null;
  28. }
  29. }