日期:2014-05-20 浏览次数:20701 次
package test; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class panel { public static void main(String[] args) throws ParseException { SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.println(sm.format(new Date(System.currentTimeMillis()))); Date date = sm.parse("1985-01-01 09:12:01"); Date currentDate = new Date(System.currentTimeMillis()); if(date.compareTo(currentDate)==-1) { System.out.println("date < currentDate"); }else if(date.compareTo(currentDate)==0) { System.out.println("date = currentDate"); }else if(date.compareTo(currentDate)==1) { System.out.println("date > currentDate"); } } }