0

Why is the result of below code 1, instead of -1.

import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class Test {
 public static void main(String[] args){

        SimpleDateFormat df = new SimpleDateFormat("EEE, d MMM YYYY HH:mm:ss");
        try {
            Date thisDate= df.parse("Tue, 29 Dec 2015 22:54:40 +0530");
            Date thatDate = df.parse("Wed, 23 Dec 2015 15:41:48 +0530");

            int result=thisDate.before(thatDate)?1:-1;
            System.out.println(result);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
 }
}
Mohit Kanwar
  • 2,962
  • 7
  • 39
  • 59

0 Answers0