Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
ObjectUtil: use StringBuilder in convert time method
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Aug 23, 2023
1 parent de19552 commit 2ec630c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/net/flectone/utils/ObjectUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ public static String convertTimeToString(int timeInSeconds) {
int minutes = (timeInSeconds / 60) % 60;
int seconds = timeInSeconds % 60;

String finalString = (days > 0 ? " " + days + locale.getString("command.online.format.day") : "")
+ (hours > 0 ? " " + hours + locale.getString("command.online.format.hour") : "")
+ (minutes > 0 ? " " + minutes + locale.getString("command.online.format.minute") : "")
+ (seconds > 0 ? " " + seconds + locale.getString("command.online.format.second") : "");
StringBuilder stringBuilder = new StringBuilder();

return finalString.substring(1);
if (days > 0) stringBuilder.append(" ").append(days).append(locale.getString("command.online.format.day"));
if (hours > 0) stringBuilder.append(" ").append(hours).append(locale.getString("command.online.format.hour"));
if (minutes > 0) stringBuilder.append(" ").append(minutes).append(locale.getString("command.online.format.minute"));
if (seconds > 0) stringBuilder.append(" ").append(seconds).append(locale.getString("command.online.format.second"));

return stringBuilder.substring(1);
}

@NotNull
Expand Down

0 comments on commit 2ec630c

Please sign in to comment.