List of utility methods to do Version Convert To
int[] | versionStringToInt(String version) version String To Int String strippedVersion = version.split("-")[0]; String[] strVersions = strippedVersion.split("\\."); int[] intVersions = new int[strVersions.length]; for (int i = 0; i < strVersions.length; i++) { intVersions[i] = Integer.parseInt(strVersions[i]); return intVersions; |
int | versionStringToInt(String version) Converts a version number string to an integer for easy comparison. version = version.trim(); int[] parts = new int[3]; int partIdx = 0; boolean valid = false; for (int i = 0; i < version.length(); i++) { char c = version.charAt(i); if (c >= '0' && c <= '9') { parts[partIdx] = parts[partIdx] * 10 + (c - '0'); ... |
int | versionStringToNumber(String versionStr) Converts a version string, such as "1.12.5 alpha" to a number. String[] strs = versionStr.trim().split(" "); strs = strs[0].split("."); if (strs.length == 1) { return Integer.parseInt(strs[0]) * 100 * 100; if (strs.length == 2) { if (Integer.parseInt(strs[1]) > 99) { throw new IllegalArgumentException("subversion too large"); ... |
int | versionToCode(String version) version To Code return Integer.parseInt(version.replaceAll("\\.", "")); |
int[] | versionToSegments(String versionString, int idx, int i) version To Segments int c, d, a; c = versionString.codePointAt(idx); idx = versionString.offsetByCodePoints(idx, 1); d = Character.digit(c, 10); if (d == -1) { throw new IllegalArgumentException("String is not in version format"); a = d; ... |
String | versionToString(int version) version To String return new StringBuilder().append(version >>> 16).append('.').append((version >>> 8) & 0xFF).append('.') .append(version & 0xFF).toString(); |
String | versiontostring(int vv) versiontostring String vs = Integer.toString(vv); return Integer.toString(Integer.parseInt(vs.substring(1, 3))) + "." + Integer.toString(Integer.parseInt(vs.substring(3, 5))) + "." + Integer.toString(Integer.parseInt(vs.substring(5))); |
String | VersionToString(long uVersion) Version To String return VersionToString(uVersion, 1);
|