Example usage for org.joda.time Seconds getSeconds

List of usage examples for org.joda.time Seconds getSeconds

Introduction

In this page you can find the example usage for org.joda.time Seconds getSeconds.

Prototype

public int getSeconds() 

Source Link

Document

Gets the number of seconds that this period represents.

Usage

From source file:org.superfuntime.chatty.chat.ChatListener.java

License:Open Source License

@Listener
public void chatMessageReceived(ChatReceivedEvent event) {
    ChatMessage message = event.getMessage();
    if (message.getType() != ChatMessage.Type.SAID)
        return; //Only said messages
    Seconds secDiff = Seconds.secondsBetween(new DateTime(message.getTime()),
            new DateTime(Calendar.getInstance().getTime()));
    if (secDiff.getSeconds() > 120)
        return; //Don't reply to old messages
    logger.trace("Received '{}' from '{}'", message.getContent(), message.getSender().getDisplayName());
    CommandManager.parse(message);//w  w w.  j a  v  a 2 s . c o m
}

From source file:playground.johannes.gsv.synPop.invermo.Date2TimeTask.java

License:Open Source License

@Override
public void apply(ProxyPlan plan) {
    LocalDateTime reference = null;

    for (ProxyObject leg : plan.getLegs()) {
        String start = leg.getAttribute(CommonKeys.LEG_START_TIME);
        if (start != null) {
            if (reference == null) {
                reference = getReference(start);
            }/*w ww .  j  a  v a2 s.  c  om*/

            LocalDateTime startDate = SplitPlanTask.formatter.parseLocalDateTime(start);
            Seconds secs = Seconds.secondsBetween(reference, startDate);

            leg.setAttribute(CommonKeys.LEG_START_TIME, String.valueOf(secs.getSeconds()));
            if (!leg.getAttributes().containsKey(MIDKeys.PERSON_MONTH)) {
                setPlanDate(startDate, plan);
            }
        }

        String end = leg.getAttribute(CommonKeys.LEG_END_TIME);
        if (end != null) {
            if (reference == null) {
                reference = getReference(end);
            }

            LocalDateTime endDate = SplitPlanTask.formatter.parseLocalDateTime(end);
            Seconds secs = Seconds.secondsBetween(reference, endDate);

            leg.setAttribute(CommonKeys.LEG_END_TIME, String.valueOf(secs.getSeconds()));

            if (!leg.getAttributes().containsKey(MIDKeys.PERSON_MONTH)) {
                setPlanDate(endDate, plan);
            }
        }
    }

}

From source file:youtube.YoutubeApiClient.java

/**
 * // ww  w  .  ja  va  2 s. com
 * @param response
 *            gets the detailed informations JSON produced eariler,
 *            containing all informations about a sinlge video
 * @param youtubeTemp
 *            is a reference to the youtube object we try to fill in the for
 *            loop
 * 
 *            the method iterates over the details JSON and fills all fields
 * @throws java.text.ParseException
 */

private YoutubeMetaData processingDetailedResults(JSONObject response, YoutubeMetaData youtubeTemp) {
    JSONArray responseItems = (JSONArray) response.get("items");
    JSONObject responseItemsEntry = (JSONObject) responseItems.get(0);
    JSONObject responseSnippet = (JSONObject) responseItemsEntry.get("snippet");
    JSONObject responseStatus = (JSONObject) responseItemsEntry.get("status");
    System.out.println("channelId " + responseSnippet.get("channelId").toString());
    youtubeTemp.setChannelID(responseSnippet.get("channelId").toString());
    youtubeTemp.setTitle(responseSnippet.get("title").toString());
    System.out.println("title: " + responseSnippet.get("title").toString());
    String tempDate = responseSnippet.get("publishedAt").toString();
    DateFormat formatter = new SimpleDateFormat("yyyy-mm-dd'T'HH:mm:ss");
    Date date = null;
    try {
        date = formatter.parse(tempDate);
    } catch (java.text.ParseException e) {
        e.printStackTrace();
        return null;
    }
    youtubeTemp.setPublishedAt(date);
    System.out.println("publishedAt: " + youtubeTemp.getPublishedAt());
    JSONObject responseContentDetails = (JSONObject) responseItemsEntry.get("contentDetails");
    youtubeTemp.setDuration(responseContentDetails.get("duration").toString());
    PeriodFormatter pf = ISOPeriodFormat.standard();
    Period p = pf.parsePeriod(responseContentDetails.get("duration").toString());
    Seconds s = p.toStandardSeconds();
    System.out.println("durationInSecond:  " + s.getSeconds());
    youtubeTemp.setDurationInSeconds(s.getSeconds());
    System.out.println("duration " + responseContentDetails.get("duration").toString());
    JSONObject responseStatistics = (JSONObject) responseItemsEntry.get("statistics");
    youtubeTemp.setViewCount(responseStatistics.get("viewCount").toString());
    System.out.println("viewCount" + responseStatistics.get("viewCount").toString());
    youtubeTemp.setLikeCount(responseStatistics.get("likeCount").toString());
    System.out.println("likeCount" + responseStatistics.get("likeCount").toString());
    youtubeTemp.setDislikeCount(responseStatistics.get("dislikeCount").toString());
    System.out.println("dislikeCount" + responseStatistics.get("dislikeCount").toString());
    youtubeTemp.setCommentCount(responseStatistics.get("commentCount").toString());
    System.out.println("commentCount" + responseStatistics.get("commentCount").toString());
    boolean isCreativeCommon = false;
    if (responseStatus.get("license").toString() == "creativeCommon")
        isCreativeCommon = true;
    youtubeTemp.setCreativeCommon(isCreativeCommon);
    System.out.println("creativeCommon: " + youtubeTemp.isCreativeCommon());
    System.out.println("------------------------------");
    return youtubeTemp;
}