Java Code Examples for org.apache.commons.lang3.math.NumberUtils#max()

The following examples show how to use org.apache.commons.lang3.math.NumberUtils#max() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommonsExample.java    From pragmatic-java-engineer with GNU General Public License v3.0 6 votes vote down vote up
public static void lang() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    String[] strs = new String[]{"1", "4", "2"};
    ArrayUtils.addAll(strs, "3");

    RandomUtils.nextInt(0, 10);
    RandomStringUtils.random(3);

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    stopWatch.split();
    stopWatch.getSplitTime();
    stopWatch.suspend();
    stopWatch.resume();
    stopWatch.stop();
    stopWatch.getTime();

    long max = NumberUtils.max(new long[]{1, 5, 10}); //计算数组最大值

    MethodUtils.invokeStaticMethod(StringUtils.class, "isNotBlank", "test"); //调用静态方法
    MethodUtils.invokeMethod(StringUtils.class, "isNotBlank", "test"); //调用静态方法

    DateUtils.truncate(new Date(), Calendar.HOUR);
    DateFormatUtils.format(new Date(), "yyyyMMdd");
}
 
Example 2
Source File: NumberAggregationHelper.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Nullable
public Double max() {
    if (items.isEmpty()) {
        return null;
    }

    return NumberUtils.max(ArrayUtils.toPrimitive(items.toArray(new Double[items.size()])));
}
 
Example 3
Source File: MaxValueInArray.java    From levelup-java-examples with Apache License 2.0 4 votes vote down vote up
@Test
public void find_max_value_in_array_with_apache_commons () {
	int highest = NumberUtils.max(numbers);
	assertEquals(91, highest);
}
 
Example 4
Source File: FormatTools.java    From px2rwd-intellij-plugin with MIT License 2 votes vote down vote up
/**
 * 取一个长度单位的起始index
 *
 * @param content 待处理文本
 * @return 返回文本中包含的一个长度单位的起始index
 */
private int getNearCode(String content) {
    return NumberUtils.max(StringUtils.lastIndexOf(content, COLON_STRING), StringUtils.lastIndexOf(content, BLANK_STRING));
}