Wednesday 5 December 2018

Dates Compare

         
       ------------------Date Compare-------------------------



 

        String valid_until = "01/12/2018";
        String valid_until1 = "02/12/2018";
        String valid_until4 = "02/12/2018";
        String valid_until2 = "08/12/2018";
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        Date strDate = null;
        Date strDate1 = null;
        Date strDate2 = null;
        Date strDate3 = null;
        try {
            strDate = sdf.parse(valid_until);
            strDate1 = sdf.parse(valid_until1);
            strDate2 = sdf.parse(valid_until2);
            strDate3 = sdf.parse(valid_until4);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        if (strDate1.getTime() > strDate.getTime()) {
            Log.v(TAG, "data :1");
        }
         if (strDate1.getTime() < strDate2.getTime()) {
            Log.v(TAG, "data :2");
        }
         if (strDate1.getTime() == strDate3.getTime()) {
            Log.v(TAG, "data :4");
        }

No comments:

Post a Comment

AutoComplete Address (Updated)

-------------------------------------Activity---------------------------------- package placeautocomplete.iteritory.com; import androi...