Java Utililty Methods Number Range Create

List of utility methods to do Number Range Create

Description

The list of methods to do Number Range Create are organized into topic(s).

Method

intrange(int unit)
Don't get excited.
switch (unit) {
case YEARS:
    return Integer.MAX_VALUE;
case MONTHS:
    return 12;
case DAYS:
    return 30;
case HOURS:
...
intrange(int v, int min, int max)
range
return min(max(v, min), max);
intrange(int value, int min, int max)
range
if (value < min)
    return min;
if (value > max)
    return max;
return value;
Integer[]range(Integer from, Integer to)
Generate a range between two bounds
Integer[] result = new Integer[to - from + 1];
for (int i = from; i <= to; i++) {
    result[i - from] = i;
return result;
doublerange(long array[])
range
return (max(array, array.length) - min(array, array.length));
long[]range(long start, long end)
range
long[] values = new long[(int) Math.abs(end - start) + 1];
if (end < start) {
    long oldstart = start;
    start = end;
    end = oldstart;
for (long i = start; i <= end; i++) {
    values[(int) (i - start)] = i;
...
booleanrange(String field, int start, int end)
Validate how long a field can be
if (field == null) {
    return false;
int length = field.length();
if (end >= length) {
    end = length - 1;
return (start >= 0) && (end >= 0) && (start <= end) && (length > 0);
...
String[]range(String input[], int beginIndex, int endIndex)
returns a range of a string table elements as a new string table
String ret[] = null;
if (input != null) {
    if ((beginIndex >= 0) && (endIndex < input.length) && (beginIndex <= endIndex)) {
        ret = new String[endIndex - beginIndex + 1];
        for (int i = beginIndex; i <= endIndex; i++) {
            ret[i - beginIndex] = input[i];
return ret;
Stringrange(String second, String first)
range
try {
    int from = Integer.parseInt(first);
    int to = Integer.parseInt(second);
    if (from > to) {
        int temp = from;
        from = to;
        to = temp;
    } else if (from == to)
...
Trange(T val, T min, T max)
Clips a number so it never goes above its max number or below its minimum number.
if (val.compareTo(min) < 0)
    return min;
else if (val.compareTo(max) > 0)
    return max;
else
    return val;