List of usage examples for org.joda.time DurationFieldType hours
public static DurationFieldType hours()
From source file:azkaban.app.Scheduler.java
License:Apache License
private String createPeriodString(ReadablePeriod period) { String periodStr = "n"; if (period == null) { return "n"; }/*ww w.j a v a 2s .com*/ 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 www . jav a 2 s .c o 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 ww.jav a2 s . co 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 w ww.j ava2 s . com*/ * @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 . j a va 2 s . co m 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 ww.ja va 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"; }//ww w .j ava2 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 full backups should be performed. * * @return number of hours between full backups. *//* w w w . jav a 2s . c o m*/ public int getFullBackupIntervalHours() { return fullBackupInterval.get(DurationFieldType.hours()); }
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 w w.j a v a2 s . c o 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.none.tom.simplerssreader.utils.DateUtils.java
License:Open Source License
public static String parseDate(final Context context, final Date date) { final Period period = new Period(new DateTime(date).getMillis(), System.currentTimeMillis()); final int[] plurals = { R.plurals.years, R.plurals.months, R.plurals.weeks, R.plurals.days, R.plurals.hours, R.plurals.minutes, R.plurals.less_than_minutes }; final DurationFieldType[] durationTypes = { DurationFieldType.years(), DurationFieldType.months(), DurationFieldType.weeks(), DurationFieldType.days(), DurationFieldType.hours(), DurationFieldType.minutes() }; final Resources res = context.getResources(); for (int i = 0; i < durationTypes.length; i++) { final int value = period.get(durationTypes[i]); if (value > 0) { return value + res.getQuantityString(plurals[i], value); }/*from w w w . j a va 2 s . c o m*/ } return res.getQuantityString(plurals[plurals.length - 1], 1); }