Java tutorial
//package com.java2s; /** * Transform date or time to various formats * * @copyright Copyright (C) 2012 - 2013 Information Technology Institute ITI-CERTH. All rights reserved. * @license GNU Affero General Public License version 3 or later; see LICENSE.txt * @author Dimitrios Ververidis for the Multimedia Group (http://mklab.iti.gr). * */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * Convert "yyyy-MM-dd HH:mm:ss" string to date object * * @param dateString * @return */ public static Date ConvertToDate(String dateString) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date convertedDate; try { convertedDate = dateFormat.parse(dateString); } catch (ParseException e) { e.printStackTrace(); return null; } return convertedDate; } }