Here you can find the source of toDate(String time)
public static Date toDate(String time)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static Date toDate(String time) { if (time == null) { return null; }//from w w w .ja va 2 s . c om try { TimeZone tz = TimeZone.getTimeZone("UTC"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS"); df.setTimeZone(tz); return df.parse(time); } catch (ParseException e) { e.printStackTrace(); } return null; } public static String toDate(Date date) { DateFormat df = new SimpleDateFormat("dd/MM/yy"); return df.format(date); } }