Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
Expand Down Expand Up @@ -1278,6 +1281,29 @@ public static int compare(String s1, String s2) {
return s1.compareTo(s2);
}

/**
* Convert epoch date to String like the Date.toString().
*
* @param millis number of milliseconds since the epoch
* @return a String with the date
*/
public static final String datetoString(long millis) {

return Instant.ofEpochMilli(millis)
.atZone(ZoneId.systemDefault())
.format(DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH));
}

/**
* Convert the current date to String like the Date.toString().
*
* @return a String with the date
*/
public static final String datetoString() {

return datetoString(System.currentTimeMillis());
}

//
// Constructor
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,18 @@ public static <E> void removeAllNull(Collection<E> collection) {

collection.removeAll(toRemove);
}

/**
* Sleep several milliseconds without throwing an exception.
*
* @param millis milliseconds to sleep
*/
public static final void silentSleep(int millis) {

try {
Thread.sleep(millis);
} catch (InterruptedException e) {
// Do not handle interruption exception
}
}
}