Java Utililty Methods Second Get

List of utility methods to do Second Get

Description

The list of methods to do Second Get are organized into topic(s).

Method

StringgetSecondsAsClock(int time)
get Seconds As Clock
int hour = time * 20 / HOUR;
int minute = (time * 20 - hour * HOUR) / MINUTE;
int second = (time * 20 - hour * HOUR - minute * MINUTE) / SECOND;
return String.format("%02d:%02d:%02d", hour, minute, second);
intgetSecondsByDays(int days)
get Seconds By Days
return days * 24 * 60 * 60;
intgetSecondsForShortString(String string)
get Seconds For Short String
int res = 0;
string = string.trim();
String c;
String curNum = "";
for (int n = 0; n < string.length(); n++) {
    c = String.valueOf(string.charAt(n));
    if (c.matches("\\d")) {
        curNum += c;
...
longgetSecondsFromEpoch()
Get the current timestamp in seconds (from the epoch).
long now = System.currentTimeMillis() / 1000;
return now;
intgetSecondsFromHMS(String hmsvalue)
Convertie quelque chose comme 123:45:12 donne 445512
if (hmsvalue.length() < 7) {
    return -1;
try {
    int secs = Integer.valueOf(hmsvalue.substring(hmsvalue.length() - 2, hmsvalue.length()));
    int mins = Integer.valueOf(hmsvalue.substring(hmsvalue.length() - 5, hmsvalue.length() - 3));
    int hours = Integer.valueOf(hmsvalue.substring(0, hmsvalue.length() - 6));
    return (hours * 3600) + (mins * 60) + secs;
...
intgetSecondsFromString(String s)
get Seconds From String
String modifier = "none";
char c = s.charAt(s.length() - 1);
modifier = c >= '0' && c <= '9' ? "none" : Character.toString(c).toLowerCase();
if (!modifier.equals("none")) {
    s = s.substring(0, s.length() - 1);
int mult = getMultiplierForModifier(modifier);
return Integer.parseInt(s) * mult;
...
doublegetSecondsFromString(String text)
Returns the number of seconds represented by a colon-delimited string.
double seconds = 0.0;
text = text.trim();
if (text.indexOf(":") > -1) {
    String[] timeArray = text.split(":");
    if ((timeArray.length > 4) || (timeArray.length < 1)) {
        throw new NumberFormatException();
    switch (timeArray.length) {
...
longgetSecondsFromStringDuration(String duration)
get Seconds From String Duration
long result = 0;
String[] tokens = duration.split("[:\\.]");
int hours = Integer.parseInt(tokens[0]);
int minutes = Integer.parseInt(tokens[1]);
int seconds = Integer.parseInt(tokens[2]);
int tenthMillis = Integer.parseInt(tokens[3]);
result += hours * 3600;
result += minutes * 60;
...
StringgetSecondSimpleType(String completeType)
Returns the second type contained as a sub type of a MAP
if (completeType.contains("<") && completeType.contains(">")) {
    return completeType.substring(completeType.indexOf(",") + 1, completeType.indexOf(">"));
} else
    throw new ClassNotFoundException();
StringgetSecondsInDDHHMMSS(int s)
get Seconds In DDHHMMSS
if (s < 0) {
    s = 0;
StringBuilder result = new StringBuilder();
String DD = "";
String HH = "";
String MM = "";
String SS = "";
...