is Same Day by converting date to string - Android java.util

Android examples for java.util:Day

Description

is Same Day by converting date to string

Demo Code

import android.util.Log;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class Main{

    public static boolean isSameDay(Date date1, Date date2) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String ds1 = sdf.format(date1);
        String ds2 = sdf.format(date2);
        if (ds1.equals(ds2)) {
            return true;
        } else {/*from   www .j av a2 s . c  o m*/
            return false;
        }
    }

}

Related Tutorials