Time time = new Time(); time.setMinutes(min); time.setSeconds(sec);
/** * Creates a string representation of the time object. * The string is returned on the form m:ss, * where m is variable digits minutes and ss is two digits seconds. * * @return a string representation of the time object * @see #toString(String) */ public String toString() { return "" + getMinutes() + ":" + (getSeconds() < 10 ? "0" : "") + getSeconds(); }
String format(Time t) { // Negative number of digits, means all seconds, no padding if (digits < 0) { return Integer.toString(t.getTime()); } // If seconds is more than digits long, simply return it if (t.getSeconds() >= Math.pow(10, digits)) { return Integer.toString(t.getSeconds()); } // Else return it with leading 0's //return StringUtil.formatNumber(t.getSeconds(), digits); return StringUtil.pad("" + t.getSeconds(), digits, "0", true); } }
/** * Sets the seconds part of the time. Note, if the seconds argument is 60 * or greater, the value will "wrap", and increase the minutes also. * * @param pSeconds an integer that should be between 0 and 59. */ public void setSeconds(int pSeconds) { time = getMinutes() * SECONDS_IN_MINUTE + pSeconds; }
/** * Creates a new time with the given time (in seconds). */ public Time(int pTime) { setTime(pTime); }
/** * Sets the minutes part of the time. * * @param pMinutes an integer */ public void setMinutes(int pMinutes) { time = pMinutes * SECONDS_IN_MINUTE + getSeconds(); }
time = new Time();
String format(Time t) { // If minutes is more than digits long, simply return it if (t.getMinutes() >= Math.pow(10, digits)) { return Integer.toString(t.getMinutes()); } // Else return it with leading 0's //return StringUtil.formatNumber(t.getMinutes(), digits); return StringUtil.pad("" + t.getMinutes(), digits, "0", true); } }
/** * Creates a new time with the given time (in seconds). */ public Time(int pTime) { setTime(pTime); }
/** * Sets the minutes part of the time. * * @param pMinutes an integer */ public void setMinutes(int pMinutes) { mTime = pMinutes * SECONDS_IN_MINUTE + getSeconds(); }
time = new Time();
Time time = new Time(); time.setMinutes(min); time.setSeconds(sec);
/** * Creates a string representation of the time object. * The string is returned on the form m:ss, * where m is variable digits minutes and ss is two digits seconds. * * @return a string representation of the time object * @see #toString(String) */ public String toString() { return "" + getMinutes() + ":" + (getSeconds() < 10 ? "0" : "") + getSeconds(); }
String format(Time t) { // Negative number of digits, means all seconds, no padding if (mDigits < 0) { return Integer.toString(t.getTime()); } // If seconds is more than mDigits long, simply return it if (t.getSeconds() >= Math.pow(10, mDigits)) { return Integer.toString(t.getSeconds()); } // Else return it with leading 0's //return StringUtil.formatNumber(t.getSeconds(), mDigits); return com.twelvemonkeys.lang.StringUtil.pad("" + t.getSeconds(), mDigits, "0", true); } }
/** * Sets the seconds part of the time. Note, if the seconds argument is 60 * or greater, the value will "wrap", and increase the minutes also. * * @param pSeconds an integer that should be between 0 and 59. */ public void setSeconds(int pSeconds) { time = getMinutes() * SECONDS_IN_MINUTE + pSeconds; }
/** * Creates a new time with the given time (in seconds). */ public Time(int pTime) { setTime(pTime); }
/** * Sets the minutes part of the time. * * @param pMinutes an integer */ public void setMinutes(int pMinutes) { time = pMinutes * SECONDS_IN_MINUTE + getSeconds(); }
time = new Time();
Time time = new Time(); time.setMinutes(min); time.setSeconds(sec);
/** * Creates a string representation of the time object. * The string is returned on the form m:ss, * where m is variable digits minutes and ss is two digits seconds. * * @return a string representation of the time object * @see #toString(String) */ public String toString() { return "" + getMinutes() + ":" + (getSeconds() < 10 ? "0" : "") + getSeconds(); }