Java Utililty Methods Second

List of utility methods to do Second

Description

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

Method

DateaddSecond(Date beginDate, int addcount)
add Second
Calendar cal = Calendar.getInstance();
cal.setTime(beginDate);
cal.add(Calendar.SECOND, addcount);
Date enddate = cal.getTime();
return enddate;
DateaddSeconds(Date date, int m)
add Seconds
return new Date(date.getTime() + m * 1000);
StringaddTimes(String dateTime, int second)
add Times
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
java.util.Date date1 = null;
try {
    date1 = format.parse(dateTime);
} catch (ParseException e) {
    e.printStackTrace();
long Time = (date1.getTime() / 1000) + second;
...
voidadvanceCurrentTimeSeconds()
Wait until the System#currentTimeMillis / 1000 advances.
long currentTimeSeconds = System.currentTimeMillis() / 1000;
do {
    Thread.sleep(50);
} while (currentTimeSeconds == System.currentTimeMillis() / 1000);
StringBuilderappendSeconds(StringBuilder time, long seconds)
append Seconds
if (seconds > 0) {
    if (seconds < 60) {
        time.append(seconds);
    } else {
        appendMinutes(time, seconds / 60);
        time.append(seconds % 60);
    time.append(" s ");
...
voidappendSecondsToEncodeOutput(StringBuilder sb, int sec, int fsec, int precision, boolean fillzeros)
Append sections and fractional seconds (if any) at *cp.
if (fsec == 0) {
    if (fillzeros)
        sb.append(String.format("%02d", Math.abs(sec)));
    else
        sb.append(String.format("%d", Math.abs(sec)));
} else {
    if (fillzeros) {
        sb.append(String.format("%02d", Math.abs(sec)));
...
StringasStringInSeconds(long duration)
as String In Seconds
long seconds = duration / 1000;
long milliSeconds = duration - (seconds * 1000);
return String.valueOf(seconds) + "." + asThreeDigits(milliSeconds);
longbytesPerSecond(long totalByteCount, long elapsed)
bytes Per Second
return (long) (((double) totalByteCount / (double) elapsed) * MILLIS);
intcalculateSeconds(long duration)
calculate Seconds
return (int) duration / 1000;
LongcountSecond(Long time)
count Second
return time / 1000;