We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
public static String formatTime(long ms, String[] magnitudes) { final int SECOND = 1000; final int MINUTE = 60 * SECOND; final int HOUR = 60 * MINUTE; final int DAY = 24 * HOUR; final long MONTH = 30L * DAY; final long YEAR = 365L * DAY; String year = " " + magnitudes[0]; String years = " " + magnitudes[1]; String month = " " + magnitudes[2]; String months = " " + magnitudes[3]; String day = " " + magnitudes[4]; String days = " " + magnitudes[5]; String hour = " " + magnitudes[6]; String hours = " " + magnitudes[7]; String minute = " " + magnitudes[8]; String minutes = " " + magnitudes[9]; String lessThanAMinuteAgo = " " + magnitudes[10]; StringBuilder sb = new StringBuilder(); if (ms >= YEAR) { if (ms < YEAR * 2) { return sb.append(ms / YEAR).append(year).toString(); } else { return sb.append(ms / YEAR).append(years).toString(); } } if (ms >= MONTH) { if (ms < MONTH * 2) { return sb.append(ms / MONTH).append(month).toString(); } else { return sb.append(ms / MONTH).append(months).toString(); } } if (ms >= DAY) { if (ms < DAY * 2) { return sb.append(ms / DAY).append(day).toString(); } else { return sb.append(ms / DAY).append(days).toString(); } } if (ms >= HOUR) { if (ms < HOUR * 2) { return sb.append(ms / HOUR).append(hour).toString(); } else { return sb.append(ms / HOUR).append(hours).toString(); } } if (ms >= MINUTE) { if (ms < MINUTE * 2) { return sb.append(ms / MINUTE).append(minute).toString(); } else { return sb.append(ms / MINUTE).append(minutes).toString(); } } return sb.append(lessThanAMinuteAgo).toString(); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: