Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #51 and restored compatibility with Java 8 #52

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@
</developers>

<properties>
<!-- Java 11 -->
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<!-- Java 8 -->
<maven.compiler.release>8</maven.compiler.release>

<!-- UTF-8 -->
<project.build.encoding>UTF-8</project.build.encoding>
Expand Down Expand Up @@ -108,7 +106,7 @@
<version>3.6.3</version>
<configuration>
<detectJavaApiLink>false</detectJavaApiLink>
<source>${maven.compiler.target}</source>
<source>${maven.compiler.release}</source>
<show>public</show>
<notimestamp>true</notimestamp>
</configuration>
Expand Down Expand Up @@ -247,7 +245,7 @@
<linkXref>true</linkXref>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
<minimumTokens>50</minimumTokens>
<targetJdk>${maven.compiler.target}</targetJdk>
<targetJdk>${maven.compiler.release}</targetJdk>
<rulesets>
<ruleset>src/test/resources/pmd.xml</ruleset>
</rulesets>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/sentrysoftware/printf4j/Printf4J.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static long toLong(final Object o) {
// 25fix will convert to 25 (any numeric prefix will work)
while (length > 0) {
try {
return Long.parseLong(s, 0, length, 10);
return Long.parseLong(s.substring(0, length));
} catch (NumberFormatException nfe) {
length--;
}
Expand Down Expand Up @@ -205,8 +205,8 @@ public static String sprintf(final Locale locale, final String format, final Obj
// adapt the behavior of Java's Formatter to be like C's sprintf()
Matcher percentMatcher = PERCENT_PATTERN.matcher(format);

// Result will be hold in a StringBuilder
StringBuilder formatResultBuilder = new StringBuilder();
// Result will be hold in a StringBuffer (for Java 8 compatibility)
StringBuffer formatResultBuilder = new StringBuffer();

// We will use a single Formatter instance (closeable)
try (Formatter formatter = new Formatter(formatResultBuilder, locale)) {
Expand Down