Here you can find the source of parseDateOrTimeString(String aDateString, String aFormatString)
private static Calendar parseDateOrTimeString(String aDateString, String aFormatString) throws ParseException
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { private static Calendar parseDateOrTimeString(String aDateString, String aFormatString) throws ParseException { Calendar tempCalendar = Calendar.getInstance(); tempCalendar.setTime(getSimpleDateFormat(aFormatString).parse(aDateString)); return tempCalendar; }//from www .ja va 2 s . c o m /** * Creates a preconfigured {@link SimpleDateFormat} for the given format string which can be used by the class * internally. * * @param aFormatString * the format string to use * @return the date format instance */ private static SimpleDateFormat getSimpleDateFormat(String aFormatString) { SimpleDateFormat tempFormat = new SimpleDateFormat(aFormatString); tempFormat.setLenient(false); return tempFormat; } }