Example usage for org.joda.time Duration getStandardHours

List of usage examples for org.joda.time Duration getStandardHours

Introduction

In this page you can find the example usage for org.joda.time Duration getStandardHours.

Prototype

public long getStandardHours() 

Source Link

Document

Gets the length of this duration in hours assuming that there are the standard number of milliseconds in an hour.

Usage

From source file:org.imsglobal.lti.toolProvider.ResourceLinkShareKey.java

License:Apache License

/**
 * Load the resource link share key from the database.
 *///w  w  w  .  j a v  a  2s  . co  m
private void load() {

    initialize();
    dataConnector.loadResourceLinkShareKey(this);
    if (id != null) {
        length = String.valueOf(id).length();
    }
    if (expires != null) {
        Duration duration = new Duration(expires, DateTime.now());
        life = duration.getStandardHours();
    }

}

From source file:org.smartdeveloperhub.harvesters.it.testing.generator.ProjectActivityGenerator.java

License:Apache License

private void estimateIssue(final Issue issue, final Set<Item> changes, final LocalDateTime now) {
    final LocalDateTime dueTo = Utils.toLocalDateTime(issue.getDueTo());
    final Duration oldValue = issue.getEstimatedTime();
    Duration newValue = null;
    do {// w w  w.  j  a v  a  2  s. co  m
        newValue = estimateEffort(now, dueTo);
        if (MINIMUM_EFFORT.isEqual(newValue) && MINIMUM_EFFORT.isEqual(oldValue)) {
            return;
        }
    } while (newValue.isEqual(oldValue));

    issue.setEstimatedTime(newValue);

    final EstimatedTimeChangeItem item = new EstimatedTimeChangeItem();
    item.setOldValue(oldValue);
    item.setNewValue(newValue);
    changes.add(item);

    if (oldValue == null) {
        LOGGER.trace("     + Estimated {} hours", newValue.getStandardHours());
    } else {
        LOGGER.trace("     + Reestimated from {} to {} hours", oldValue.getStandardHours(),
                newValue.getStandardHours());
    }
}

From source file:org.tanrabad.survey.utils.time.DurationTimePrinter.java

License:Apache License

public static String print(DateTime startTime, DateTime endTime) {
    Duration duration = new Duration(startTime, endTime);
    if (duration.getStandardHours() > 0)
        return String.format(Locale.US, "%d:%02d:%02d", duration.getStandardHours(),
                duration.getStandardMinutes() % 60, duration.getStandardSeconds() % 60);
    else/*from www. ja  v a 2s . c om*/
        return String.format(Locale.US, "%02d:%02d", duration.getStandardMinutes(),
                duration.getStandardSeconds() % 60);
}

From source file:SkynetBot.DBAccess.java

License:Open Source License

public String getLastSeen(String user, Channel channel) {
    Connection con;//from   ww  w .j  a  va  2s  . c o  m
    String last = "No records found for a resistance member named " + user + ".";
    DateTimeFormatter format = DateTimeFormat.forPattern("CCYY-MM-dd HH:mm:ss.S");

    try {
        con = pool.getConnection(timeout);

        PreparedStatement s = con
                .prepareStatement("SELECT `last_seen` FROM `users` WHERE `name` = ? AND `channel` = ?");
        s.setString(1, user.toLowerCase());
        s.setString(2, channel.getName().toLowerCase());
        s.executeQuery();

        ResultSet rs = s.getResultSet();
        while (rs.next()) {
            DateTime dateTime = format.parseDateTime(rs.getString("last_seen"));

            Duration duration = new Duration(dateTime, new DateTime());

            if (duration.getStandardMinutes() < 120) {
                last = "Resistance member " + user + " was last seen " + duration.getStandardMinutes()
                        + " minutes ago. Surveillance is ongoing.";
            } else if (duration.getStandardHours() < 48) {
                last = "Resistance member " + user + " was last seen " + duration.getStandardHours()
                        + " hours ago. Surveillance is ongoing.";
            } else {
                last = "Resistance member " + user + " was last seen " + duration.getStandardDays()
                        + " days ago. Surveillance is ongoing.";
            }
        }

        con.close();
    } catch (Exception ex) {
        last = "ERROR! Data records corrupted! Resistance activity suspected.";
        Logger.getLogger(DBAccess.class.getName()).log(Level.SEVERE, null, ex);
    }

    return last;
}