ZGC runs not often enough. GC logs show that it runs once every 2-3 minutes for my application and because of this, my memory usage goes high between GC cycles (as high as 90%). After GC, it drops to as low as 20%. How to increase GC run’s frequency to run more often? Answer -XX:ZCollectionInterval=N – set maximum gap between
Tag: java-11
Java convert DateTime from “yyyy-MM-dd HH:mm:ss.SSSSSSS” to “yyyy-MM-dd HH:mm:ss.S” or from “yyyy-MM-dd HH:mm:ss.SSSSSSS” to “yyyy-MM-dd HH:mm:ss.SSS”
Java 11 I want to convert the date in “yyyy-MM-dd HH:mm:ss.SSSSSSS” to either “yyyy-MM-dd HH:mm:ss.S” or “yyyy-MM-dd HH:mm:ss.SSS” based on milliseconds value. If milliseconds are all zeros, then I just want single zero but if it is non-zero value then I want just value omitting trailing zeros. Example : Input : 2021-03-10 16:37:02.4230000 => Desired Output : 2021-03-10 16:37:02.423 Input : 2021-03-10 16:39:51.0000000
Java 8 edit stream elements
I need to filter and modify the values of the filtered object. The logic that must be filtered is given below. I have tried it like this. But how can we set the value of isUpdated = true using java 8? Answer Base on the logic given, findFirst should be used as you stop after the first instance is found.
Which version of OpenJFX (JavaFX) and Scene Builder should I use with Amazon Corretto 11 (OpenJDK)?
In your opinion, what is the best version of OpenJFX (JavaFX) and Scene Builder should I use with Amazon Corretto 11 (OpenJDK)? Currently, until the date of this post, there are 2 versions of OpenJFX (JavaFX) and 2 versions of Scene Builder: Gluon’s JavaFX versions: JavaFX 11 LTS JavaFX 16 Latest Release Gluon’s Scene Builder versions: Scene Builder 16 Scene
Deprecated Short(String) how to update?
I’m handling this problem: Short appears deprecated with a mark. How can I update this for above Java 9 versions? (Now, I have Java 11) Answer You shall use Short.valueOf. This is taken from the javadoc Deprecated. It is rarely appropriate to use this constructor. The static factory valueOf(short) is generally a better choice, as it is likely to yield
Discrepancies between Java 11 and Java 8 DecimalFormat behaviour
I’ve got a weird issue with Java 11. I’m porting a huge project, and I have some tests which use DecimalFormat failing on the 11 build, but not on the 8 build. DecimalFormat in Java 11 gives me a comma decimal separator, and on Java 8 it gives me a dot. Here is a minimal reproducible example: which outputs 1.02
Executing the single code java file using java Vs javac using jdk11
I am using JDK11. Below is my sample class – I executed the above class with command “java filename.java” for below scenarios ColumnA -> Class declared as public? ColumnB -> File name same as class name? For all the scenarios, the command executed successfully and I got the result. I get compile-time error for the “Yes-No” case, if I run
Is it possible to make a generic functional interface with optional parameter(s)?
I’m trying to create a functional interface in Java with a single method (of course) that can take any type of parameter(s) and return any data type (i.e. a generic method). This is what I have so far: Calculator.java Main.java The error says: bad operand types for binary operator ‘+’ Is it possible to create a generic functional interface with
Generate a String from all values of a specific key from List in Java?
Suppose I have a list of Map such as: (Using json format just for demonstration) Now I want all the “id” values in a single String object, separated by a separator. For example, the above map should give me: Note: The order in which they are indexed in the list has to be maintained. I know I can do it
Is it possible to exclude field-sets in AspectJ
Is it possible to exclude fiel-sets in AspectJ pointcuts, so instrumentation does not stumble over final fields in Java 11? When weaving the following aspect (the full example is here: https://github.com/DaGeRe/aspect-final-example): into by java -cp target/test-0.1-SNAPSHOT.jar -javaagent:../aspect/target/aspectjtest-0.1-SNAPSHOT.jar de.test.MainWithError I get when I execute it with OpenJDK 11 (when setting everything to Java 8, it works fine). When removing the final