How to compare system date with mydate in android 2.1?

in my android application, I am taking the date and time from the database. but I can’t get the date in Date format from the database to my application, the date is in string format, so I can’t compare the system date with the database date. if I convert the system date to a string, then I cannot update the date in the database in the repeated case. I also want to update the database date if the system date and the database date are matched.

How can I achieve this - android.

Thanks in advance.

+5
source share
2 answers

You can convert String to Date as follows:

String str = "12/12/1912";
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
Date date = formatter.parse(str);

And back to String

SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
System.out.println("Date is : " + formatter.format(date));

Date before after .

, Joda, .

+2

:

Calendar c = Calendar.getInstance();
    System.out.println("Current time => " + c.getTime());
    SimpleDateFormat df = new SimpleDateFormat("dd-MMMM");
    formattedDate = df.format(c.getTime());
+1

All Articles