Here you can find the source of toDate(String datetime)
public static Date toDate(String datetime)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { private static final Date EPOCH = new Date(0); public static Date toDate(String datetime) { SimpleDateFormat sdf;//from ww w .j a v a 2s.c o m sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); try { return sdf.parse(datetime); } catch (ParseException e) { return EPOCH; } } }