Here you can find the source of getDateFromString(String s)
public static long getDateFromString(String s)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static long getDateFromString(String s) { int day, month, year; int i = s.indexOf('/'); if (i < 0) return 0; try {//from ww w.j a v a2 s. c o m day = Integer.parseInt(s.substring(0, i)); } catch (NumberFormatException e) { return 0; } int j = s.indexOf('/', i + 1); try { month = Integer.parseInt(s.substring(i + 1, j)); } catch (NumberFormatException e) { return 0; } try { year = Integer.parseInt(s.substring(j + 1)); } catch (NumberFormatException e) { return 0; } Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, month - 1); c.set(Calendar.DAY_OF_MONTH, day); resetHours(c); return c.getTimeInMillis(); } public static void resetHours(Calendar c) { c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); } }