Question

Sorry if the title is confusing, I'll explain: I am making an app which registers an action of the user, writes it in the database as a string (like this, 17JUL2014 17:45), and then, from when the first entry is created I have to measure 3 days, so when those 3 days pass, I will prompt the user to do something. How will I be able to do that?

Was it helpful?

Solution

you should use Unix time and save it as long.

 long time = System.currentTimeMillis();

3 days difference:

 boolean isThreeDaysDifference(long savedTime){
        if(System.currentTimeMillis() - savedTime > 1000*3600*24*3)
          return true;
      return false;
 }

EDIT corrected the value

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top