Here you can find the source of parseDateTime(String format, String dateStr)
Parameter | Description |
---|---|
format | format pattern, e.g. DATE_TIME_FORMAT_WITH_SECONDS. |
dateStr | string to parse. |
public static Date parseDateTime(String format, String dateStr) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from www . java 2s. c om*/ * Parses specified date string according to format. * * @param format format pattern, e.g. DATE_TIME_FORMAT_WITH_SECONDS. * @param dateStr string to parse. */ public static Date parseDateTime(String format, String dateStr) throws ParseException { if ((format == null) || (dateStr == null)) { return null; } SimpleDateFormat formatter = new SimpleDateFormat(format); formatter.setLenient(false); return formatter.parse(dateStr); } }