-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
per
committed
Dec 27, 2021
1 parent
28df0f8
commit 1d3ceb0
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package se.alipsa.ride.utils; | ||
|
||
|
||
public final class JavaVersion { | ||
|
||
private JavaVersion() { | ||
// Utility class | ||
} | ||
|
||
/** | ||
* | ||
* @return the java version currently running | ||
* for java < 9 the right-hand side will be returned e.g 1.8 will become 8 | ||
*/ | ||
public static int specVersion() { | ||
double jvmVersion = Double.parseDouble(System.getProperty("java.specification.version")); | ||
if (jvmVersion < 2) { | ||
jvmVersion = (jvmVersion - 1) * 10; | ||
} | ||
return (int)Math.round(jvmVersion); | ||
} | ||
} |