Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static boolean isBeforeTime(String date1, String date2) { try { SimpleDateFormat dfDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return dfDateFormat.parse(date1).before(dfDateFormat.parse(date2)); } catch (ParseException e) { e.printStackTrace(); } return false; } }