Here you can find the source of parseDateTime(String s)
public static long parseDateTime(String s)
//package com.java2s; /******************************************************************************* * Copyright (C) 2006-2013 AITIA International, Inc. * /*from www . ja va 2 s. co m*/ * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ import java.text.DateFormat; public class Main { /** Parses a date from a string. */ public static long parseDateTime(String s) { DateFormat df = null; for (int i = 0; true; ++i) { switch (i) { case 0: df = new java.text.SimpleDateFormat("MMM d, yyyy K:m:s a", java.util.Locale.ENGLISH); break; case 1: df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, java.util.Locale.ENGLISH); break; case 2: df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); break; case 3: df = DateFormat.getDateTimeInstance(); break; case 4: df = new java.text.SimpleDateFormat("MM/dd/yyyy kk:mm:ss", java.util.Locale.ENGLISH); break; default: return new java.util.Date().getTime(); } try { java.util.Date date = df.parse(s); return date.getTime(); } catch (java.text.ParseException e) { } } } }