Fix the failing tests.

This commit is contained in:
graywolf336 2014-08-19 14:43:03 -05:00
parent 85e1106b42
commit 6ddabe39ad
2 changed files with 7 additions and 7 deletions

View File

@ -103,7 +103,7 @@ public class Util {
msg = msg.replaceAll("%uuid%", p.getUUID().toString()); msg = msg.replaceAll("%uuid%", p.getUUID().toString());
msg = msg.replaceAll("%reason%", p.getReason()); msg = msg.replaceAll("%reason%", p.getReason());
msg = msg.replaceAll("%jailer", p.getJailer()); msg = msg.replaceAll("%jailer", p.getJailer());
msg = msg.replaceAll("%afktime%", TimeUnit.MILLISECONDS.toMinutes(p.getAFKTime()) + " mins"); msg = msg.replaceAll("%afktime%", TimeUnit.MINUTES.convert(p.getAFKTime(), TimeUnit.MILLISECONDS) + " mins");
if(p.getRemainingTime() >= 0) { if(p.getRemainingTime() >= 0) {
msg = msg.replaceAll("%timeinminutes%", String.valueOf(p.getRemainingTimeInMinutes())); msg = msg.replaceAll("%timeinminutes%", String.valueOf(p.getRemainingTimeInMinutes()));
@ -157,16 +157,16 @@ public class Util {
if (match.matches()) { if (match.matches()) {
String units = match.group(2); String units = match.group(2);
if ("seconds".equals(units) || "second".equals(units) || "s".equals(units)) if ("seconds".equals(units) || "second".equals(units) || "s".equals(units))
t = TimeUnit.MILLISECONDS.toSeconds(Long.valueOf(match.group(1))); t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.SECONDS);
else if ("minutes".equals(units) || "minute".equals(units) || "mins".equals(units) || "min".equals(units) || "m".equals(units)) else if ("minutes".equals(units) || "minute".equals(units) || "mins".equals(units) || "min".equals(units) || "m".equals(units))
t = TimeUnit.MILLISECONDS.toMinutes(Long.valueOf(match.group(1))); t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.MINUTES);
else if ("hours".equals(units) || "hour".equals(units) || "h".equals(units)) else if ("hours".equals(units) || "hour".equals(units) || "h".equals(units))
t = TimeUnit.MILLISECONDS.toHours(Long.valueOf(match.group(1))); t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.HOURS);
else if ("days".equals(units) || "day".equals(units) || "d".equals(units)) else if ("days".equals(units) || "day".equals(units) || "d".equals(units))
t = TimeUnit.MILLISECONDS.toDays(Long.valueOf(match.group(1))); t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.DAYS);
else { else {
try { try {
t = TimeUnit.MILLISECONDS.toMinutes(Long.parseLong(time)); t = TimeUnit.MILLISECONDS.convert(Long.parseLong(time), TimeUnit.MINUTES);
}catch(NumberFormatException e) { }catch(NumberFormatException e) {
throw new Exception("Invalid format."); throw new Exception("Invalid format.");
} }

View File

@ -112,7 +112,7 @@ public class Prisoner {
/** Gets the remaining time the prisoner has in minutes. */ /** Gets the remaining time the prisoner has in minutes. */
public long getRemainingTimeInMinutes() { public long getRemainingTimeInMinutes() {
return TimeUnit.MILLISECONDS.toMinutes(time); return TimeUnit.MINUTES.convert(time, TimeUnit.MILLISECONDS);
} }
/** Gets the remaining time the prison has in minutes except only in int format. */ /** Gets the remaining time the prison has in minutes except only in int format. */