Skip to content
Open
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
12 changes: 6 additions & 6 deletions src/main/java/org/utility/timeunitbuilder/HoursBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ public String build(long milliseconds) {
long hours = TimeUnit.MILLISECONDS.toHours(milliseconds);
long remainingTime = milliseconds - TimeUnit.HOURS.toMillis(hours);
if (nextFormatter != null) {
return formattedMinutes(hours) + Constants.SPACE + nextFormatter.build(remainingTime);
return formattedHours(hours) + Constants.SPACE + nextFormatter.build(remainingTime);
} else {
return formattedMinutes(hours);
return formattedHours(hours);
}
}

/**
* Method to format the minutes to the desired format.
* Formats the hours value with the appropriate unit label.
*
* @param hours the time in minutes
* @return formatted string in minutes format
* @param hours the time in hours
* @return formatted string in hours format
*/
private String formattedMinutes(long hours) {
private String formattedHours(long hours) {
return hours + Constants.SPACE + (hours > 1 ? Constants.HOURS : Constants.HOUR);
}
}