b**t 发帖数: 33 | 1 i am trying to do a simple parse and compare program for date comparison
import java.text.*;
import java.util.Date;
public class DateTest {
public static void main(String[] args) throws Exception {
SimpleDateFormat formatter = new SimpleDateFormat("MMM dd yyyy");
Date d1 = formatter.parse("aug 04 2004");
Date d2 = formatter.parse("may 06 2004");
Date d3 = formatter.parse("mar 18 2004");
System.out.println("d1 to d2:"+d1.compareTo(d2));
System.out.println("d1 to d3:"+d1.compareTo(d3));
System.out |
xt 发帖数: 17532 | 2
The result is right, but your understanding is totally wrong.
【在 b**t 的大作中提到】 : i am trying to do a simple parse and compare program for date comparison : import java.text.*; : import java.util.Date; : public class DateTest { : public static void main(String[] args) throws Exception { : SimpleDateFormat formatter = new SimpleDateFormat("MMM dd yyyy"); : Date d1 = formatter.parse("aug 04 2004"); : Date d2 = formatter.parse("may 06 2004"); : Date d3 = formatter.parse("mar 18 2004"); : System.out.println("d1 to d2:"+d1.compareTo(d2));
|
j*****k 发帖数: 1198 | 3 XT is right
【在 xt 的大作中提到】 : : The result is right, but your understanding is totally wrong.
|