Here you can find the source of parse(String dateStr)
Parameter | Description |
---|---|
dateStr | a parameter |
public static Date parse(String dateStr)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final SimpleDateFormat defaultFormater = new SimpleDateFormat("yyyyMMdd"); private static final SimpleDateFormat customizedFormater = new SimpleDateFormat("yyyyMMdd"); public static Date parse(String dateStr, String pattern) { synchronized (customizedFormater) { if (null != pattern && !"".equals(pattern.trim())) { customizedFormater.applyPattern(pattern); } else { throw new IllegalArgumentException("pattern can not be empty"); }// ww w . j a v a 2s .c om try { return customizedFormater.parse(dateStr); } catch (ParseException e) { throw new RuntimeException(e.getMessage()); } } } public static Date parse(String dateStr) { synchronized (defaultFormater) { try { return defaultFormater.parse(dateStr); } catch (ParseException e) { throw new RuntimeException(e.getMessage()); } } } }