Example usage for org.joda.time Days compareTo

List of usage examples for org.joda.time Days compareTo

Introduction

In this page you can find the example usage for org.joda.time Days compareTo.

Prototype

public int compareTo(BaseSingleFieldPeriod other) 

Source Link

Document

Compares this period to another object of the same class.

Usage

From source file:org.zanata.client.commands.UpdateChecker.java

License:Open Source License

public boolean needToCheckUpdates(boolean interactiveMode) {
    DateTime today = new DateTime();
    try {// w  ww .  ja  va2s.c o m
        if (!updateMarker.exists()) {
            createUpdateMarkerFile(updateMarker);
            console.printfln(_("update.marker.created"), updateMarker);
            console.printfln(_("update.marker.hint"));
            return true;
        }
        // read the content and see if we need to check
        Properties props = loadFileToProperties(updateMarker);
        DateTime lastCheckedDate = readLastCheckedDate(props);
        Days daysPassed = Days.daysBetween(lastCheckedDate, today);
        Frequency frequency = readFrequency(props);
        boolean timeToCheck = daysPassed.compareTo(frequency.days()) >= 0;
        boolean noAsking = readNoAsking(props);
        if (timeToCheck && !noAsking && interactiveMode) {
            console.printf(_("check.update.yes.no"), daysPassed.getDays());
            String check = console.expectAnswerWithRetry(AnswerValidator.YES_NO);
            if (check.toLowerCase().startsWith("n")) {
                return false;
            }
        }
        return timeToCheck;
    } catch (Exception e) {
        log.debug("Error checking update marker file", e);
        log.warn("Error checking update marker file {}", updateMarker);
        log.warn("Please make sure its permission and content format");
        return false;
    }
}