/**
* Constructs a new version object by parsing a version string, which is assumed to be of the form: <major-version>.<minor-version>-<patch-version>
* @param versionString The version string to parse for the major, minor and patch version numbers.
* @throws ParseException If the version string parameter was not able to be parsed into the expected format.
*/
public AmiToolsVersion(String versionString) throws ParseException {
String parseExceptionMessage="Version string '" + versionString + "' does not start with version number in the form "+ "'<major-version>.<minor-version>-<patch-version>'";
Matcher matcher=pattern.matcher(versionString);
if (!matcher.matches()) {
throw new ParseException(parseExceptionMessage,-1);
}
try {
majorVersion=Integer.parseInt(matcher.group(1));
minorVersion=Integer.parseInt(matcher.group(2));
patch=Integer.parseInt(matcher.group(3));
}
catch ( Throwable t) {
throw new ParseException(parseExceptionMessage,-1);
}
}

Example 5

From project Birthday-widget, under directory /Birthday/src/main/java/cz/krtinec/birthday/data/.