Here you can find the source of formattedDateToDate(String str)
Parameter | Description |
---|---|
str | the string to parse |
public static java.util.Date formattedDateToDate(String str)
//package com.java2s; /*//from www . j a v a2 s . c om * Copyright (c) 1995-2003 by Gregory M. Messner * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * For more information contact the author at: gmessner@messners.com * */ public class Main { /** * Returns a Date object parsed from the date-time string formatted * in accordance with RFC 822. * * @param str the string to parse */ public static java.util.Date formattedDateToDate(String str) { java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", java.util.Locale.US); java.text.ParsePosition pos = new java.text.ParsePosition(0); try { return (df.parse(str, pos)); } catch (Exception ignore) { return (null); } } }