Posted on 2015-10-15 12:31
朱杰兵 阅读(248)
评论(0) 编辑 收藏
package cn.javase.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class BeforeDate {
public static void main(String[] args) throws Exception {
java.util.Date nowdate=new java.util.Date();
String myString = "2008/09/02";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd", Locale.CHINA);
Date d = sdf.parse(myString);
boolean flag = d.before(nowdate);
if(flag){
System.out.print("早于今天") ;
}else{
System.out.print("晚于今天") ;
}
}
}