List of usage examples for org.joda.time DurationFieldType minutes
public static DurationFieldType minutes()
From source file:azkaban.app.Scheduler.java
License:Apache License
private String createPeriodString(ReadablePeriod period) { String periodStr = "n"; if (period == null) { return "n"; }//from w ww . ja va 2 s. c o m 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 va 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/*from w w w.j a va 2 s.c om*/ * @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// w ww .j a v a 2 s . 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"; }/* ww w .j a v a2 s . 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 w w w.jav a 2 s. c o m 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"; }//from w ww. ja v a2 s . c om 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:com.google.jenkins.plugins.cloudbackup.CloudBackupJenkinsModule.java
License:Open Source License
/** * Returns the interval that incremental backups should be performed. * * @return number of minutes between incremental backups. *///from w ww. j a va 2 s . co m public int getIncrementalBackupIntervalMinutes() { return incrementalBackupInterval.get(DurationFieldType.minutes()); }
From source file:com.jbirdvegas.mgerrit.search.AgeSearch.java
License:Apache License
/** * Adds adjustment to the shortest set time range in period. E.g. * period("5 days 3 hours", 1) -> "5 days 4 hours". This will fall * back to adjusting years if no field in the period is set. * @param period The period to be adjusted * @param adjustment The adjustment. Note that positive values will result * in larger periods and an earlier time * @return The adjusted period/*w ww .ja v a 2 s. co m*/ */ private Period adjust(final Period period, int adjustment) { if (adjustment == 0) return period; // Order is VERY important here LinkedHashMap<Integer, DurationFieldType> map = new LinkedHashMap<>(); map.put(period.getSeconds(), DurationFieldType.seconds()); map.put(period.getMinutes(), DurationFieldType.minutes()); map.put(period.getHours(), DurationFieldType.hours()); map.put(period.getDays(), DurationFieldType.days()); map.put(period.getWeeks(), DurationFieldType.weeks()); map.put(period.getMonths(), DurationFieldType.months()); map.put(period.getYears(), DurationFieldType.years()); for (Map.Entry<Integer, DurationFieldType> entry : map.entrySet()) { if (entry.getKey() > 0) { return period.withFieldAdded(entry.getValue(), adjustment); } } // Fall back to modifying years return period.withFieldAdded(DurationFieldType.years(), adjustment); }
From source file:com.metinkale.prayerapp.vakit.times.Times.java
License:Apache License
public String getLeft(int next, boolean showsecs) { LocalDateTime date = getTimeCal(null, next); Period period = new Period(LocalDateTime.now(), date, PeriodType.dayTime()); if (showsecs) { return Utils.toArabicNrs(PERIOD_FORMATTER_HMS.print(period)); } else if (Prefs.isDefaultWidgetMinuteType()) { return Utils.toArabicNrs(PERIOD_FORMATTER_HM.print(period)); } else {// w w w . ja v a2 s. co m period = period.withFieldAdded(DurationFieldType.minutes(), 1); return Utils.toArabicNrs(PERIOD_FORMATTER_HM.print(period)); } }