Gets the duration setting and converts it to days.
<p/>
The setting must be use one of the following conventions:
<ul>
<li>n MILLISECONDS
<li>n SECONDS
<li>n MINUTES
<li>n HOURS
<li>n DAYS
</ul>

@param name
@param defaultValue in days
@return days
432175
public long getDurationInDays(String name, long defaultValue) {
        TimeUnit timeUnit = extractTimeUnit(name, defaultValue + " DAYS");
        long duration = getLong(name, defaultValue);

        return timeUnit.toDays(duration);
    }
811508
public int getAsInt(final String name, final int defaultValue) {
        return AtsdUtil.getPropertyIntValue(fullName(name), clientProperties, defaultValue);
    }
633844
public static StringBuilder durationConfigString(Duration duration) {
        Duration remainder = duration;

        long days = remainder.getStandardDays();
        remainder = remainder.minus(Duration.standardDays(days));

        long hours = remainder.getStandardHours();
        remainder = remainder.minus(Duration.standardHours(hours));

        long minutes = remainder.getStandardMinutes();
        remainder = remainder.minus(Duration.standardMinutes(minutes));

        long seconds = remainder.getStandardSeconds();
        remainder = remainder.minus(Duration.standardSeconds(seconds));

        if (!remainder.isEqual(Duration.ZERO))
            Logger.getLogger(ConfigSupport.class.getName()).log(Level.WARNING, "Duration is more precise than configuration will handle: {0}, dropping remainder: {1}", new Object[]{duration, remainder});

        StringBuilder result = new StringBuilder();
        if (days != 0) {
            if (result.length() != 0) result.append(' ');
            result.append(days).append('d');
        }
        if (hours != 0) {
            if (result.length() != 0) result.append(' ');
            result.append(hours).append('h');
        }
        if (minutes != 0) {
            if (result.length() != 0) result.append(' ');
            result.append(minutes).append('m');
        }
        if (result.length() == 0 || seconds != 0) {
            if (result.length() != 0) result.append(' ');
            result.append(seconds).append('s');
        }

        return result;
    }
704579
public String getCookie(String name, String defaultValue) {
		Cookie cookie = getCookieObject(name);
		return cookie != null ? cookie.getValue() : defaultValue;
	}
573840
public static DateTimeValue toDateTimeValue(long millisFromEpoch, TimeZone zone) {
		GregorianCalendar c = new GregorianCalendar(zone);
		c.clear();
		c.setTimeInMillis(millisFromEpoch);
		//@formatter:off
		return new DateTimeValueImpl (
			c.get(Calendar.YEAR),
			c.get(Calendar.MONTH) + 1,
			c.get(Calendar.DAY_OF_MONTH),
			c.get(Calendar.HOUR_OF_DAY),
			c.get(Calendar.MINUTE),
			c.get(Calendar.SECOND)
		);
		//@formatter:on
	}
190667
public static Long toLong(Object value, Long defaultValue) {
		return convert(Long.class, value, defaultValue);
	}
1123998
public com.google.type.TimeOfDayOrBuilder getTimeValueOrBuilder() {
    if (typeCase_ == 6) {
      return (com.google.type.TimeOfDay) type_;
    }
    return com.google.type.TimeOfDay.getDefaultInstance();
  }
721409
public com.google.protobuf.Duration getDefaultCookieExpiration() {
    return defaultCookieExpiration_ == null ? com.google.protobuf.Duration.getDefaultInstance() : defaultCookieExpiration_;
  }
910
private Duration getDuration(TimeUnit units, Double duration)
   {
      Duration result = null;
      if (duration != null)
      {
         double durationValue = duration.doubleValue() * 100.0;

         switch (units)
         {
            case MINUTES:
            {
               durationValue *= MINUTES_PER_DAY;
               break;
            }

            case HOURS:
            {
               durationValue *= HOURS_PER_DAY;
               break;
            }

            case DAYS:
            {
               durationValue *= 3.0;
               break;
            }

            case WEEKS:
            {
               durationValue *= 0.6;
               break;
            }

            case MONTHS:
            {
               durationValue *= 0.15;
               break;
            }

            default:
            {
               throw new IllegalArgumentException("Unsupported time units " + units);
            }
         }

         durationValue = Math.round(durationValue) / 100.0;

         result = Duration.getInstance(durationValue, units);
      }

      return result;
   }
890566
public String getFormAttribute(@NotNull final String name, String defaultValue) {
        String value = request.formAttributes().get(name);

        if (value == null) {
            return defaultValue;
        }

        return value;
    }
962155
public GregorianCalendar getValueAsCalendar() {
		if (getValue() == null) {
			return null;
		}
		GregorianCalendar cal;
		if (getTimeZone() != null) {
			cal = new GregorianCalendar(getTimeZone());
		} else {
			cal = new GregorianCalendar();
		}
		cal.setTime(getValue());
		return cal;
	}
929268
static public String convertStringFromDuration(
            Duration duration, DurationConverterSettings settings) {
        if ((duration == null) || (duration.isNegative())) {
            return "";
        }
        long seconds = duration.getSeconds();

        HashSet<DurationUnit> usedUnits
                = getUsedDurationUnitSet(settings.smallestUsedUnit, settings.largestUsedUnit);
        if (usedUnits.isEmpty()) {
            throw new RuntimeException("convertStringFromDuration(), The \"used duration unit\" "
                    + "variables do not allow any units to be used.");
        }
        boolean hasNoNanos = (duration.getNano() == 0);

        DurationUnit smallestUnit = settings.smallestUsedUnit;
        HashMap<DurationUnit, String> unitsSingular = settings.translationsUnitsSingular;
        HashMap<DurationUnit, String> unitsPlural = settings.translationsUnitsPlural;
        HashMap<DurationUnit, Boolean> pluralRules = settings.pluralUnitsMap;
        int oneYear = DurationUnit.Year.inSeconds;
        int oneMonth = DurationUnit.Month.inSeconds;
        int oneWeek = DurationUnit.Week.inSeconds;
        int oneDay = DurationUnit.Day.inSeconds;
        int oneHour = DurationUnit.Hour.inSeconds;
        int oneMinute = DurationUnit.Minute.inSeconds;
        int thirtyMinutes = DurationUnit.Second.thirtyMinutesInSeconds;

        String result = "";
        long value;
        boolean yearIsBestChoice = usedUnits.contains(DurationUnit.Year) && hasNoNanos
                && (seconds >= oneYear) && (seconds % oneYear == 0);
        if (yearIsBestChoice || (DurationUnit.Year == smallestUnit)) {
            value = seconds / oneYear;
            result += value + " ";
            result += ((pluralRules.get(DurationUnit.Year) && (value != 1))
                    ? unitsPlural.get(DurationUnit.Year) : unitsSingular.get(DurationUnit.Year));
            return result;
        }
        boolean monthIsBestChoice = usedUnits.contains(DurationUnit.Month) && hasNoNanos
                && (seconds >= oneMonth) && (seconds % oneMonth == 0);
        if (monthIsBestChoice || (DurationUnit.Month == smallestUnit)) {
            value = seconds / oneMonth;
            result += value + " ";
            result += ((pluralRules.get(DurationUnit.Month) && (value != 1))
                    ? unitsPlural.get(DurationUnit.Month) : unitsSingular.get(DurationUnit.Month));
            return result;
        }
        boolean weekIsBestChoice = usedUnits.contains(DurationUnit.Week) && hasNoNanos
                && (seconds >= oneWeek) && (seconds % oneWeek == 0);
        if (weekIsBestChoice || (DurationUnit.Week == smallestUnit)) {
            value = seconds / oneWeek;
            result += value + " ";
            result += ((pluralRules.get(DurationUnit.Week) && (value != 1))
                    ? unitsPlural.get(DurationUnit.Week) : unitsSingular.get(DurationUnit.Week));
            return result;
        }
        boolean dayIsBestChoice = usedUnits.contains(DurationUnit.Day) && hasNoNanos
                && (seconds >= oneDay) && (seconds % oneDay == 0);
        if (dayIsBestChoice || (DurationUnit.Day == smallestUnit)) {
            value = seconds / oneDay;
            result += value + " ";
            result += ((pluralRules.get(DurationUnit.Day) && (value != 1))
                    ? unitsPlural.get(DurationUnit.Day) : unitsSingular.get(DurationUnit.Day));
            return result;
        }

        boolean hourDecimalIsBestChoice = settings.hoursCanUseThirtyMinuteDecimals
                && usedUnits.contains(DurationUnit.Hour) && hasNoNanos
                && (seconds >= oneHour) && (seconds <= settings.hoursMaximumValueForDecimalsInSeconds)
                && (seconds % thirtyMinutes == 0) && (seconds % oneHour != 0);
        // Note, hourDecimal is never forced to be used as the "smallest used unit".
        if (hourDecimalIsBestChoice) {
            value = seconds / oneHour;
            // The full value is always "X.5" hour(s), due to the hourDecimalIsBestChoice criteria. 
            String decimalString = ".5";
            result += value + decimalString + " ";
            result += ((pluralRules.get(DurationUnit.Hour))
                    ? unitsPlural.get(DurationUnit.Hour) : unitsSingular.get(DurationUnit.Hour));
            return result;
        }

        boolean hourIntegerIsBestChoice = usedUnits.contains(DurationUnit.Hour) && hasNoNanos
                && (seconds >= oneHour) && (seconds % oneHour == 0);
        if (hourIntegerIsBestChoice || (DurationUnit.Hour == smallestUnit)) {
            value = seconds / oneHour;
            result += value + " ";
            result += ((pluralRules.get(DurationUnit.Hour) && (value != 1))
                    ? unitsPlural.get(DurationUnit.Hour) : unitsSingular.get(DurationUnit.Hour));
            return result;
        }

        boolean minuteIsBestChoice = usedUnits.contains(DurationUnit.Minute) && hasNoNanos
                && (seconds >= oneMinute) && (seconds % oneMinute == 0);
        if (minuteIsBestChoice || (DurationUnit.Minute == smallestUnit)) {
            value = seconds / oneMinute;
            result += value + " ";
            result += ((pluralRules.get(DurationUnit.Minute) && (value != 1))
                    ? unitsPlural.get(DurationUnit.Minute) : unitsSingular.get(DurationUnit.Minute));
            return result;
        }

        boolean secondIsBestChoice = usedUnits.contains(DurationUnit.Second);
        if (secondIsBestChoice || (DurationUnit.Second == smallestUnit)) {
            value = seconds;
            int nanosecondsFromDuration = duration.getNano();
            boolean includeNanoseconds = (nanosecondsFromDuration != 0);
            BigDecimal nanosecondsInSeconds = BigDecimal.valueOf(nanosecondsFromDuration, 9);
            BigDecimal secondsWithNanosAdded = nanosecondsInSeconds.add(new BigDecimal(value));
            secondsWithNanosAdded = secondsWithNanosAdded.stripTrailingZeros();
            result += ((includeNanoseconds) ? secondsWithNanosAdded.toPlainString() : value);
            result += " ";
            result += (pluralRules.get(DurationUnit.Second) && ((value != 1) || (includeNanoseconds)))
                    ? unitsPlural.get(DurationUnit.Second) : unitsSingular.get(DurationUnit.Second);
            return result;
        }
        throw new RuntimeException("convertStringFromDuration(), "
                + "The duration unit could not be chosen. (This should not happen.)");
    }
339267
public long getLongParameter(int radix, String name, long defaultValue) {
        parseBody();
        return params.getLongValue(radix, name, defaultValue);
    }
356222
@NonNull
    public Parameters setLong(@NonNull String name, long value) {
        return setValue(name, value);
    }
974501
public static String getString(String name, String defaultVal){
        if(getConfiguration().containsKey(name)){
            return getConfiguration().getString(name);
        } else {
            return defaultVal;
        }
    }
1092075
public static DayDuration valueOf(String duration) {
		int spacePos = duration.indexOf(' ');
		if(spacePos == -1) throw new IllegalArgumentException("Space not found in duration: " + duration);
		return getInstance(
			Integer.parseInt(duration.substring(0, spacePos)),
			Unit.valueOfUnit(duration.substring(spacePos + 1))
		);
	}
1361641
public static Duration fromMillis(long milliseconds) {
		Duration.Builder builder = builder();

		if (milliseconds < 0) {
			builder.prior(true);
			milliseconds *= -1;
		}

		int seconds = (int) (milliseconds / 1000);

		Integer weeks = seconds / (60 * 60 * 24 * 7);
		if (weeks > 0) {
			builder.weeks(weeks);
		}
		seconds %= 60 * 60 * 24 * 7;

		Integer days = seconds / (60 * 60 * 24);
		if (days > 0) {
			builder.days(days);
		}
		seconds %= 60 * 60 * 24;

		Integer hours = seconds / (60 * 60);
		if (hours > 0) {
			builder.hours(hours);
		}
		seconds %= 60 * 60;

		Integer minutes = seconds / (60);
		if (minutes > 0) {
			builder.minutes(minutes);
		}
		seconds %= 60;

		if (seconds > 0) {
			builder.seconds(seconds);
		}

		return builder.build();
	}