Here you can find the source of parseTime(String time)
public static Date parseTime(String time)
//package com.java2s; //License from project: Open Source License import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date parseTime(String time) { SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MM-yyyy h.mm a"); Date temp = dateFormatter.parse(time, new ParsePosition(0)); if (temp == null) { dateFormatter = new SimpleDateFormat("dd-MM-yyyy"); temp = dateFormatter.parse(time, new ParsePosition(0)); return temp; }/*from w w w . jav a 2 s .c om*/ return temp; } }