Skip to content
Open
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
30 changes: 9 additions & 21 deletions src/main/java/com/kosherjava/zmanim/util/Zman.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Zman> DATE_ORDER = new Comparator<Zman>() {
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<Zman> 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
Expand All @@ -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<Zman> NAME_ORDER = new Comparator<Zman>() {
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<Zman> NAME_ORDER = Comparator.comparing(zman ->
zman == null || zman.getLabel() == null ? "" : zman.getLabel()
);

/**
* A {@link Comparator} that will compare and sort duration based <em>zmanim</em> such as
Expand All @@ -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<Zman> DURATION_ORDER = new Comparator<Zman>() {
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<Zman> DURATION_ORDER = Comparator.comparingLong(
zman -> zman == null ? Long.MAX_VALUE : zman.getDuration()
);

/**
* A method that returns an XML formatted <code>String</code> representing the serialized <code>Object</code>. Very
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/kosherjava/zmanim/util/ZmanimFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading