Download the formatter and run it with: To reformat changed lines in a specific patch, use google-java-format-diff.py. Note: There is no configurability as to the formatter's algorithm for formatting.
Note that it uses the jdk.compiler module to parse the Java source code. The java binary version used must therefore be from a JDK (not JRE) with a version equal to or newer than the Java language ...