Message-ID: From: "lukaseder (@lukaseder)" To: "pgjdbc/pgjdbc" Date: Fri, 14 Nov 2025 08:08:55 +0000 Subject: Re: [pgjdbc/pgjdbc] issue #3865: Avoid well known slow JDK libraries String.format() and DecimalFormat in PGInterval::getValue to get drastic performance boost In-Reply-To: References: List-Id: X-GitHub-Author-Login: lukaseder X-GitHub-Comment-Id: 3531477858 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 3865 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3865#issuecomment-3531477858 Content-Type: text/plain; charset=utf-8 > Well the except part is kinda important. It will probably break something Sure, you can remove the trailing zeros like this: ```java while (sb.charAt(sb.length() - 1) == '0') sb.deleteCharAt(sb.length() - 1); ``` So: ```java public String getValue() { if (isNull) { return null; } StringBuilder sb = new StringBuilder(); sb.append(years).append(" years ") .append(months).append(" mons ") .append(days).append(" days ") .append(hours).append(" hours ") .append(minutes).append(" mins "); if (wholeSeconds < 0 || microSeconds < 0) sb.append('-'); sb.append(Math.abs(wholeSeconds)); if (microSeconds != 0) { sb.append('.'); String s = "" + Math.abs(microSeconds); for (int i = s.length(); i < 6; i++) sb.append('0'); sb.append(s); while (sb.charAt(sb.length() - 1) == '0') sb.deleteCharAt(sb.length() - 1); } sb.append(" secs"); return sb.toString(); } ```