Date中有个before方法:测试此日期是否在指定日期之后。
import java.util.*;
import java.text.*;
public class Demo
{
public static void main(String args[])throws Exception
{
Date nowDate=new Date();
String myString = "2014-03-04";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date d = sdf.parse(myString);
boolean flag = d.before(nowDate);
if(flag)
System.out.print("早于今天");
else
System.out.print("晚于今天");
}
}