diff --git a/src/main/java/com/kosherjava/zmanim/util/Zman.java b/src/main/java/com/kosherjava/zmanim/util/Zman.java index f8699166..241e0540 100644 --- a/src/main/java/com/kosherjava/zmanim/util/Zman.java +++ b/src/main/java/com/kosherjava/zmanim/util/Zman.java @@ -228,13 +228,9 @@ public void setDescription(String description) { * than the second. * Please note that this class will handle cases where either the {@code Zman} is a null or {@link #getZman()} returns a null. */ - public static final Comparator DATE_ORDER = new Comparator() { - public int compare(Zman zman1, Zman zman2) { - long firstTime = (zman1 == null || zman1.getZman() == null) ? Long.MAX_VALUE : zman1.getZman().toEpochMilli(); - long secondTime = (zman2 == null || zman2.getZman() == null) ? Long.MAX_VALUE : zman2.getZman().toEpochMilli(); - return Long.compare(firstTime, secondTime); - } - }; + public static final Comparator DATE_ORDER = Comparator.comparingLong(zman -> + zman == null || zman.getZman() == null ? Long.MAX_VALUE : zman.getZman().toEpochMilli() + ); /** * A {@link Comparator} that will compare and sort zmanim by zmanim label order. Compares its two arguments by the zmanim label @@ -243,13 +239,9 @@ public int compare(Zman zman1, Zman zman2) { * Please note that this class will sort cases where either the {@code Zman} is a null or {@link #label} returns a null * as empty {@code String}s. */ - public static final Comparator NAME_ORDER = new Comparator() { - public int compare(Zman zman1, Zman zman2) { - String firstLabel = (zman1 == null || zman1.getLabel() == null) ? "" : zman1.getLabel(); - String secondLabel = (zman2 == null || zman2.getLabel() == null) ? "" : zman2.getLabel(); - return firstLabel.compareTo(secondLabel); - } - }; + public static final Comparator NAME_ORDER = Comparator.comparing(zman -> + zman == null || zman.getLabel() == null ? "" : zman.getLabel() + ); /** * A {@link Comparator} that will compare and sort duration based zmanim such as @@ -259,13 +251,9 @@ public int compare(Zman zman1, Zman zman2) { * integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. * Please note that this class will sort cases where {@code Zman} is a null. */ - public static final Comparator DURATION_ORDER = new Comparator() { - public int compare(Zman zman1, Zman zman2) { - long firstDuration = zman1 == null ? Long.MAX_VALUE : zman1.getDuration(); - long secondDuration = zman2 == null ? Long.MAX_VALUE : zman2.getDuration(); - return Long.compare(firstDuration, secondDuration); - } - }; + public static final Comparator DURATION_ORDER = Comparator.comparingLong( + zman -> zman == null ? Long.MAX_VALUE : zman.getDuration() + ); /** * A method that returns an XML formatted String representing the serialized Object. Very diff --git a/src/main/java/com/kosherjava/zmanim/util/ZmanimFormatter.java b/src/main/java/com/kosherjava/zmanim/util/ZmanimFormatter.java index de7e7e0d..f78dedfd 100644 --- a/src/main/java/com/kosherjava/zmanim/util/ZmanimFormatter.java +++ b/src/main/java/com/kosherjava/zmanim/util/ZmanimFormatter.java @@ -320,13 +320,13 @@ public String formatXSDDurationTime(Time time) { duration.append("T"); if (time.getHours() != 0) - duration.append(time.getHours() + "H"); + duration.append(time.getHours()).append("H"); if (time.getMinutes() != 0) - duration.append(time.getMinutes() + "M"); + duration.append(time.getMinutes()).append("M"); if (time.getSeconds() != 0 || time.getMilliseconds() != 0) { - duration.append(time.getSeconds() + "." + milliNF.format(time.getMilliseconds())); + duration.append(time.getSeconds()).append(".").append(milliNF.format(time.getMilliseconds())); duration.append("S"); } if (duration.length() == 1) // zero seconds