Java Code Examples for org.apache.commons.lang3.math.NumberUtils#createLong()
The following examples show how to use
org.apache.commons.lang3.math.NumberUtils#createLong() .
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: ArchivaRuntimeInfo.java From archiva with Apache License 2.0 | 6 votes |
@Inject public ArchivaRuntimeInfo( @Named( value = "archivaRuntimeProperties" ) Properties archivaRuntimeProperties ) { this.version = (String) archivaRuntimeProperties.get( "archiva.version" ); this.buildNumber = (String) archivaRuntimeProperties.get( "archiva.buildNumber" ); String archivaTimeStamp = (String) archivaRuntimeProperties.get( "archiva.timestamp" ); if ( NumberUtils.isNumber( archivaTimeStamp ) ) { this.timestamp = NumberUtils.createLong( archivaTimeStamp ); } else { this.timestamp = new Date().getTime(); } this.devMode = Boolean.getBoolean( "archiva.devMode" ); }
Example 2
Source File: NumberUtilities.java From cs-actions with Apache License 2.0 | 5 votes |
/** * Given a long integer string, it checks if it's a valid long integer (based on apaches NumberUtils.createLong) * * @param longStr the long integer string to check * @return true if it's valid, otherwise false */ public static boolean isValidLong(@Nullable final String longStr) { if (StringUtils.isBlank(longStr)) { return false; } final String stripedLong = StringUtils.strip(longStr); try { NumberUtils.createLong(stripedLong); return true; } catch (NumberFormatException e) { return false; } }
Example 3
Source File: NumberUtilities.java From cs-actions with Apache License 2.0 | 5 votes |
/** * Given a long integer string if it's a valid long (see isValidLong) it converts it into a long integer otherwise it throws an exception * * @param longStr the long integer to convert * @return the long integer value of the longStr * @throws IllegalArgumentException if the passed long integer string is not a valid long value */ public static long toLong(@Nullable final String longStr) { if (!isValidLong(longStr)) { throw new IllegalArgumentException(longStr + ExceptionValues.EXCEPTION_DELIMITER + ExceptionValues.INVALID_LONG_VALUE); } final String stripedLong = StringUtils.strip(longStr); return NumberUtils.createLong(stripedLong); }