Brief Java question:
I have this code:
// edited above
} else if ((now >= (1000 * 60 * 60 * 24) && (now < (1000 * 60 * 60 * 48)))) {
now = (now / (1000 * 60 * 60 * 24));
time = String.valueOf(now + " day ago");
} else if ((now >= (1000 * 60 * 60 * 48) && (now < (1000 * 60 * 60 * 24 * 30)))) {
now = (now / (1000 * 60 * 60 * 24));
time = String.valueOf(now + " days ago");
You can see what I am doing. If something happened between 24-48 hours ago, it was "1 day ago", but if it was between 48 hours and 1 month (or 30 days) it was "X day*s* ago." I am not sure how to put the month in this situation. If I delete the right side of the second if
statement... it works. It will say 3 days ago, or 15 days ago, of 376 days ago. Obviously, after 30 days, I want it to say over 1 month ago.... but based on how it is, something that is, for example, 15 days ago, will not register inside that clause and it will skip. Am I missing something really small here?
Supplementary code:
Here is the entire thing in context; everything works up until "days":
lCDateTime = Calendar.getInstance();
now = lCDateTime.getTimeInMillis();
now = now - total;
if (now <= ((1000 * 60 * 1))) {
now = (now / 1000);
time = String.valueOf(now + " seconds ago");
} else if ((now > (1000 * 60 * 1)) && (now < 1000 * 60 * 2)) {
now = (now / (1000 * 60));
time = String.valueOf(now + " minute ago");
} else if ((now >= (1000 * 60 * 2)) && (now < 1000 * 60 * 60)) {
now = (now / (1000 * 60));
time = String.valueOf(now + " minutes ago");
} else if ((now >= (1000 * 60 * 60) && now < (1000 * 60 * 60 * 2))) {
now = (now / (1000 * 60 * 60));
time = String.valueOf(now + " hour ago");
} else if ((now >= (1000 * 60 * 60 * 2) && (now < (1000 * 60 * 60 * 24)))) {
now = (now / (1000 * 60 * 60));
time = String.valueOf(now + " hours ago");
} else if ((now >= (1000 * 60 * 60 * 24) && (now < (1000 * 60 * 60 * 48)))) {
now = (now / (1000 * 60 * 60 * 24));
time = String.valueOf(now + " day ago");
} else if ((now >= (1000 * 60 * 60 * 48) && (now < (1000 * 60 * 60 * 24 * 30)))) {
now = (now / (1000 * 60 * 60 * 24));
time = String.valueOf(now + " days ago");