如何在java中比较以下两个日期。我的情况是
String dt1="2013/01/08";
Date f=Calendar.getInstance().getTime();
and how to add time(hh:mm:ss.ms) to the date string(i mean to dt1)eg. 2013/01/08 21:10:01.23
如何在java中比较以下两个日期。我的情况是
String dt1="2013/01/08";
Date f=Calendar.getInstance().getTime();
and how to add time(hh:mm:ss.ms) to the date string(i mean to dt1)eg. 2013/01/08 21:10:01.23
String dt1="2013/01/08";
Date f=Calendar.getInstance().getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
System.out.println(sdf.parse(dt1).after(f));
您也可以使用compareTo方法
String dt1="2013/01/08";
Date f=Calendar.getInstance().getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
System.out.println(sdf.parse(dt1).compareTo(f);