Example usage for org.joda.time ReadablePeriod get

List of usage examples for org.joda.time ReadablePeriod get

Introduction

In this page you can find the example usage for org.joda.time ReadablePeriod get.

Prototype

int get(DurationFieldType field);

Source Link

Document

Gets the value of one of the fields.

Usage

From source file:azkaban.app.Scheduler.java

License:Apache License

private String createPeriodString(ReadablePeriod period) {
    String periodStr = "n";

    if (period == null) {
        return "n";
    }//  w  w  w. j  ava 2  s. c  om

    if (period.get(DurationFieldType.days()) > 0) {
        int days = period.get(DurationFieldType.days());
        periodStr = days + "d";
    } else if (period.get(DurationFieldType.hours()) > 0) {
        int hours = period.get(DurationFieldType.hours());
        periodStr = hours + "h";
    } else if (period.get(DurationFieldType.minutes()) > 0) {
        int minutes = period.get(DurationFieldType.minutes());
        periodStr = minutes + "m";
    } else if (period.get(DurationFieldType.seconds()) > 0) {
        int seconds = period.get(DurationFieldType.seconds());
        periodStr = seconds + "s";
    }

    return periodStr;
}

From source file:azkaban.migration.scheduler.Schedule.java

License:Apache License

public static String createPeriodString(ReadablePeriod period) {
    String periodStr = "n";

    if (period == null) {
        return "n";
    }/*from   w w w  .j  a v  a  2 s .  co m*/

    if (period.get(DurationFieldType.months()) > 0) {
        int months = period.get(DurationFieldType.months());
        periodStr = months + "M";
    } else if (period.get(DurationFieldType.weeks()) > 0) {
        int weeks = period.get(DurationFieldType.weeks());
        periodStr = weeks + "w";
    } else if (period.get(DurationFieldType.days()) > 0) {
        int days = period.get(DurationFieldType.days());
        periodStr = days + "d";
    } else if (period.get(DurationFieldType.hours()) > 0) {
        int hours = period.get(DurationFieldType.hours());
        periodStr = hours + "h";
    } else if (period.get(DurationFieldType.minutes()) > 0) {
        int minutes = period.get(DurationFieldType.minutes());
        periodStr = minutes + "m";
    } else if (period.get(DurationFieldType.seconds()) > 0) {
        int seconds = period.get(DurationFieldType.seconds());
        periodStr = seconds + "s";
    }

    return periodStr;
}

From source file:azkaban.utils.TimeUtils.java

License:Apache License

/**
 * Format ReadablePeriod object to string
 *
 * @param period readable period object/*  w w w .  ja v  a2 s  .  c  o  m*/
 * @return String presentation of ReadablePeriod Object
 */
public static String formatPeriod(final ReadablePeriod period) {
    String periodStr = "null";

    if (period == null) {
        return periodStr;
    }

    if (period.get(DurationFieldType.years()) > 0) {
        final int years = period.get(DurationFieldType.years());
        periodStr = years + " year(s)";
    } else if (period.get(DurationFieldType.months()) > 0) {
        final int months = period.get(DurationFieldType.months());
        periodStr = months + " month(s)";
    } else if (period.get(DurationFieldType.weeks()) > 0) {
        final int weeks = period.get(DurationFieldType.weeks());
        periodStr = weeks + " week(s)";
    } else if (period.get(DurationFieldType.days()) > 0) {
        final int days = period.get(DurationFieldType.days());
        periodStr = days + " day(s)";
    } else if (period.get(DurationFieldType.hours()) > 0) {
        final int hours = period.get(DurationFieldType.hours());
        periodStr = hours + " hour(s)";
    } else if (period.get(DurationFieldType.minutes()) > 0) {
        final int minutes = period.get(DurationFieldType.minutes());
        periodStr = minutes + " minute(s)";
    } else if (period.get(DurationFieldType.seconds()) > 0) {
        final int seconds = period.get(DurationFieldType.seconds());
        periodStr = seconds + " second(s)";
    }

    return periodStr;
}

From source file:azkaban.utils.TimeUtils.java

License:Apache License

/**
 * Convert ReadablePeriod Object to string
 *
 * @param period ReadablePeriod Object/*from  ww  w.j  av  a 2s . c o  m*/
 * @return string formatted ReadablePeriod Object
 */
public static String createPeriodString(final ReadablePeriod period) {
    String periodStr = "null";

    if (period == null) {
        return periodStr;
    }

    if (period.get(DurationFieldType.years()) > 0) {
        final int years = period.get(DurationFieldType.years());
        periodStr = years + "y";
    } else if (period.get(DurationFieldType.months()) > 0) {
        final int months = period.get(DurationFieldType.months());
        periodStr = months + "M";
    } else if (period.get(DurationFieldType.weeks()) > 0) {
        final int weeks = period.get(DurationFieldType.weeks());
        periodStr = weeks + "w";
    } else if (period.get(DurationFieldType.days()) > 0) {
        final int days = period.get(DurationFieldType.days());
        periodStr = days + "d";
    } else if (period.get(DurationFieldType.hours()) > 0) {
        final int hours = period.get(DurationFieldType.hours());
        periodStr = hours + "h";
    } else if (period.get(DurationFieldType.minutes()) > 0) {
        final int minutes = period.get(DurationFieldType.minutes());
        periodStr = minutes + "m";
    } else if (period.get(DurationFieldType.seconds()) > 0) {
        final int seconds = period.get(DurationFieldType.seconds());
        periodStr = seconds + "s";
    }

    return periodStr;
}

From source file:azkaban.utils.Utils.java

License:Apache License

public static String createPeriodString(ReadablePeriod period) {
    String periodStr = "null";

    if (period == null) {
        return "null";
    }//from ww w  .  java 2s  . com

    if (period.get(DurationFieldType.years()) > 0) {
        int years = period.get(DurationFieldType.years());
        periodStr = years + "y";
    } else if (period.get(DurationFieldType.months()) > 0) {
        int months = period.get(DurationFieldType.months());
        periodStr = months + "M";
    } else if (period.get(DurationFieldType.weeks()) > 0) {
        int weeks = period.get(DurationFieldType.weeks());
        periodStr = weeks + "w";
    } else if (period.get(DurationFieldType.days()) > 0) {
        int days = period.get(DurationFieldType.days());
        periodStr = days + "d";
    } else if (period.get(DurationFieldType.hours()) > 0) {
        int hours = period.get(DurationFieldType.hours());
        periodStr = hours + "h";
    } else if (period.get(DurationFieldType.minutes()) > 0) {
        int minutes = period.get(DurationFieldType.minutes());
        periodStr = minutes + "m";
    } else if (period.get(DurationFieldType.seconds()) > 0) {
        int seconds = period.get(DurationFieldType.seconds());
        periodStr = seconds + "s";
    }

    return periodStr;
}

From source file:azkaban.utils.WebUtils.java

License:Apache License

public String formatPeriod(ReadablePeriod period) {
    String periodStr = "null";

    if (period == null) {
        return periodStr;
    }/*from ww  w .  jav a 2s .  com*/

    if (period.get(DurationFieldType.years()) > 0) {
        int years = period.get(DurationFieldType.years());
        periodStr = years + " year(s)";
    } else if (period.get(DurationFieldType.months()) > 0) {
        int months = period.get(DurationFieldType.months());
        periodStr = months + " month(s)";
    } else if (period.get(DurationFieldType.weeks()) > 0) {
        int weeks = period.get(DurationFieldType.weeks());
        periodStr = weeks + " week(s)";
    } else if (period.get(DurationFieldType.days()) > 0) {
        int days = period.get(DurationFieldType.days());
        periodStr = days + " day(s)";
    } else if (period.get(DurationFieldType.hours()) > 0) {
        int hours = period.get(DurationFieldType.hours());
        periodStr = hours + " hour(s)";
    } else if (period.get(DurationFieldType.minutes()) > 0) {
        int minutes = period.get(DurationFieldType.minutes());
        periodStr = minutes + " minute(s)";
    } else if (period.get(DurationFieldType.seconds()) > 0) {
        int seconds = period.get(DurationFieldType.seconds());
        periodStr = seconds + " second(s)";
    }

    return periodStr;
}

From source file:com.cenrise.test.azkaban.Utils.java

License:Apache License

public static String createPeriodString(final ReadablePeriod period) {
    String periodStr = "null";

    if (period == null) {
        return "null";
    }/* www .j a  v  a  2 s .  c o m*/

    if (period.get(DurationFieldType.years()) > 0) {
        final int years = period.get(DurationFieldType.years());
        periodStr = years + "y";
    } else if (period.get(DurationFieldType.months()) > 0) {
        final int months = period.get(DurationFieldType.months());
        periodStr = months + "M";
    } else if (period.get(DurationFieldType.weeks()) > 0) {
        final int weeks = period.get(DurationFieldType.weeks());
        periodStr = weeks + "w";
    } else if (period.get(DurationFieldType.days()) > 0) {
        final int days = period.get(DurationFieldType.days());
        periodStr = days + "d";
    } else if (period.get(DurationFieldType.hours()) > 0) {
        final int hours = period.get(DurationFieldType.hours());
        periodStr = hours + "h";
    } else if (period.get(DurationFieldType.minutes()) > 0) {
        final int minutes = period.get(DurationFieldType.minutes());
        periodStr = minutes + "m";
    } else if (period.get(DurationFieldType.seconds()) > 0) {
        final int seconds = period.get(DurationFieldType.seconds());
        periodStr = seconds + "s";
    }

    return periodStr;
}