Here you can find the source of parseDate(String dateString)
Parameter | Description |
---|---|
dateString | The date string to parse |
public static Date parseDate(String dateString)
//package com.java2s; /*//from w w w .j a v a2s.c om * $URL$ * $Author$ * $Date$ * * $Copyright-Start$ * * Copyright (c) 2010 * Sam Corporation * All Rights Reserved * * This software is furnished under a corporate license for use on a * single computer system and can be copied (with inclusion of the * above copyright) only for use on such a system. * * The information in this document is subject to change without notice * and should not be construed as a commitment by Sam Corporation. * * Sam Corporation assumes no responsibility for the use of the * software described in this document on equipment which has not been * supplied or approved by Sam Corporation. * * $Copyright-End$ */ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final DateFormat _dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); /** * Parses a MOCA date String (YYYYMMDDHHmmss) into a standard Java date object. This method * assumes that the string should be parsed in the current timezone. If the date is formatted * incorrectly, <code>null</code> is returned. * * @param dateString The date string to parse * @return The date as parsed from the string or null if invalid */ public static Date parseDate(String dateString) { if (dateString == null) return null; try { DateFormat tmp = (DateFormat) _dateFormat.clone(); tmp.setLenient(false); return tmp.parse(dateString); } catch (ParseException e) { return null; } } }