Java Utililty Methods Time to String

List of utility methods to do Time to String

Description

The list of methods to do Time to String are organized into topic(s).

Method

StringtimeToString(final long time)
time To String
long timeRemaining = time;
String timeString = "";
if (timeRemaining >= DAY) {
    final int days = (int) (timeRemaining / DAY);
    timeString = timeString.concat(days + (days == 1 ? " day " : " days "));
    timeRemaining -= days * DAY;
if (timeRemaining >= HOUR) {
...
StringtimeToString(int s)
time To String
String hs = "";
int h = 0;
int m = 0;
if (s >= 3600) {
    h = s / 3600;
    hs = " " + h + " hrs";
    s = s - h * 3600;
if ((h > 0) || (s >= 60)) {
    m = s / 60;
    hs = hs + " " + m + " min";
    s = s - m * 60;
hs = hs + " " + s + " sec";
return hs;
StringtimeToString(int time)
Converts seconds to a more friendly strings.
String message = "";
if (time > 60) {
    int minutes = (int) Math.floor(time / 60), seconds = time - (minutes * 60);
    if (minutes > 60) {
        int hours = (int) Math.floor(minutes / 60);
        minutes -= (hours * 60);
        if (hours > 24) {
            int days = (int) Math.floor(hours / 24);
...
StringtimeToString(int time)
Helper for CAST({time} AS VARCHAR(n)).
final StringBuilder buf = new StringBuilder(8);
timeToString(buf, time, 0); 
return buf.toString();
StringtimeToString(int time)
Transform secunde in format afisabil
String result = "";
int hours, minutes, seconds;
int rest;
String strHour, strMinute, strSecond;
boolean hasHours = false, hasMinutes = false;
hours = time / HOURS_2_SECONDS;
rest = time % HOURS_2_SECONDS;
minutes = rest / MINUTES_2_SECONDS;
...
StringTimeToString(int time)
Time To String
String timeAsString = "";
int highnibble = time;
int lownibble = highnibble % 16;
highnibble = (highnibble - lownibble) / 16;
double tempTime = Math.pow(2.0, highnibble) * lownibble * 0.25;
double seconds = tempTime % 60;
double minutes = (tempTime - seconds) / 60;
minutes = minutes % 60;
...
StringtimeToString(java.util.Date date)
time To String
try {
    return ((date == null) ? "" : getTimeFormatter().format(date));
} catch (Exception e) {
    return "";
StringtimeToString(long time)
Convert a given time in seconds to a more readable format
String str = "";
if ((System.currentTimeMillis() / 1000L) - time <= 0) {
    return "Not yet known";
long days = time / 86400;
time -= days * 86400;
long hours = time / 3600;
time -= hours * 3600;
...
StringtimeToString(long time)
time To String
long timeYears = time > year ? time / year : 0;
time -= timeYears * year;
long timeMonths = time > month ? time / month : 0;
time -= timeMonths * month;
long timeDays = time > day ? time / day : 0;
time -= timeDays * day;
long timeHours = time > hour ? time / hour : 0;
time -= timeHours * hour;
...
StringtimeToString(long time)
time To String
String returnTime = "";
long temp;
if (time / ONE_WEEK_IN_MILISECONDS > 0) {
    temp = time / ONE_WEEK_IN_MILISECONDS;
    returnTime += temp + "w ";
    returnTime += (time - temp * ONE_WEEK_IN_MILISECONDS) / ONE_DAY_IN_MILISECONDS + "d";
} else if (time / ONE_DAY_IN_MILISECONDS > 0) {
    temp = time / ONE_DAY_IN_MILISECONDS;
...