Add printTimestamp method

pull/253/head
Alex Baker 10 years ago
parent 8dae0aef59
commit 813eff299e

@ -19,7 +19,7 @@ import java.util.Set;
import javax.inject.Inject;
import static com.google.common.collect.Lists.newArrayList;
import static org.tasks.date.DateTimeUtils.newDateTime;
import static org.tasks.date.DateTimeUtils.printTimestamp;
public class GtasksListService {
@ -89,7 +89,7 @@ public class GtasksListService {
long lastUpdate = remoteList.getUpdated().getValue();
if (lastSync < lastUpdate) {
listsToUpdate.add(localList);
log.debug("{} out of date [local={}] [remote={}]", listName, newDateTime(lastSync), newDateTime(lastUpdate));
log.debug("{} out of date [local={}] [remote={}]", listName, printTimestamp(lastSync), printTimestamp(lastUpdate));
} else {
log.debug("{} up to date", listName);
}

@ -29,4 +29,8 @@ public class DateTimeUtils {
public static DateTime newDateTime(long timestamp) {
return new DateTime(timestamp);
}
public static String printTimestamp(long timestamp) {
return new Date(timestamp).toString();
}
}

@ -15,6 +15,7 @@ import javax.inject.Inject;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.tasks.date.DateTimeUtils.currentTimeMillis;
import static org.tasks.date.DateTimeUtils.newDateTime;
import static org.tasks.date.DateTimeUtils.printTimestamp;
public abstract class MidnightIntentService extends InjectingIntentService {
@ -38,11 +39,11 @@ public abstract class MidnightIntentService extends InjectingIntentService {
if (nextRun <= now) {
nextRun = nextMidnight(now);
log.debug("running now [nextRun={}]", newDateTime(nextRun));
log.debug("running now [nextRun={}]", printTimestamp(nextRun));
preferences.setLong(getLastRunPreference(), now);
run();
} else {
log.debug("will run at {} [lastRun={}]", newDateTime(nextRun), newDateTime(lastRun));
log.debug("will run at {} [lastRun={}]", printTimestamp(nextRun), printTimestamp(lastRun));
}
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

@ -14,7 +14,7 @@ import javax.inject.Inject;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.tasks.date.DateTimeUtils.currentTimeMillis;
import static org.tasks.date.DateTimeUtils.newDateTime;
import static org.tasks.date.DateTimeUtils.printTimestamp;
public abstract class RecurringIntervalIntentService extends InjectingIntentService {
@ -45,11 +45,11 @@ public abstract class RecurringIntervalIntentService extends InjectingIntentServ
if (nextRun < now + PADDING) {
nextRun = now + interval;
log.debug("running now [nextRun={}]", newDateTime(nextRun));
log.debug("running now [nextRun={}]", printTimestamp(nextRun));
preferences.setLong(getLastRunPreference(), now);
run();
} else {
log.debug("will run at {} [lastRun={}]", newDateTime(nextRun), newDateTime(lastRun));
log.debug("will run at {} [lastRun={}]", printTimestamp(nextRun), printTimestamp(lastRun));
}
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

Loading…
Cancel
Save