Example usage for org.joda.time Duration getStandardDays

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

Introduction

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

Prototype

public long getStandardDays() 

Source Link

Document

Gets the length of this duration in days assuming that there are the standard number of milliseconds in a day.

Usage

From source file:web.StreamMeetupComTask.java

License:Apache License

private String getUpfrontReservationTime(Long dateInMillis) {
    DateTime now = new DateTime(DateTimeZone.forTimeZone(TimeZone.getTimeZone("UTC")));
    DateTime event = new DateTime(dateInMillis, DateTimeZone.forTimeZone(TimeZone.getTimeZone("UTC")));
    Duration duration = new Duration(now, event);

    if (duration.getMillis() < 0) {
        return "-1";
    } else if (duration.getStandardSeconds() < 86400) {
        return "1d";
    } else if (duration.getStandardDays() < 4) {
        return "4d";
    } else if (duration.getStandardDays() < 7) {
        return "1w";
    } else if (duration.getStandardDays() < 14) {
        return "2w";
    } else if (duration.getStandardDays() < 28) {
        return "4w";
    } else if (duration.getStandardDays() < 56) {
        return "8w";
    } else {//from  w  ww  .  j av  a 2 s.  c o  m
        return "-";
    }
}