Here you can find the source of toDate(String sdate)
public static Date toDate(String sdate)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { private final static SimpleDateFormat dateFormater = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss", Locale.CHINA); public static Date toDate(String sdate) { try {//from ww w . ja v a 2s . co m return dateFormater.parse(sdate); } catch (ParseException e) { try { return dateFormater.parse(new Date(toLong(sdate) * 1000L) .toGMTString()); } catch (ParseException e1) { return null; } } } public static long toLong(String obj) { try { return Long.parseLong(obj); } catch (Exception e) { } return 0; } }